| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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> | 
|   11 #endif |   11 #endif | 
|   12 #include <string> |   12 #include <string> | 
|   13  |   13  | 
|   14 #include "app/l10n_util.h" |   14 #include "app/l10n_util.h" | 
|   15 #include "app/resource_bundle.h" |   15 #include "app/resource_bundle.h" | 
|   16 #include "base/file_util.h" |   16 #include "base/file_util.h" | 
|   17 #include "base/i18n/rtl.h" |   17 #include "base/i18n/rtl.h" | 
|   18 #include "base/i18n/time_formatting.h" |   18 #include "base/i18n/time_formatting.h" | 
|   19 #include "base/path_service.h" |   19 #include "base/path_service.h" | 
|   20 #include "base/singleton.h" |   20 #include "base/singleton.h" | 
|   21 #include "base/string_util.h" |   21 #include "base/string_util.h" | 
|   22 #include "base/utf_string_conversions.h" |   22 #include "base/utf_string_conversions.h" | 
|   23 #include "base/values.h" |   23 #include "base/values.h" | 
|   24 #include "chrome/browser/browser_process.h" |   24 #include "chrome/browser/browser_process.h" | 
|   25 #include "chrome/browser/download/download_item_model.h" |   25 #include "chrome/browser/download/download_item_model.h" | 
|   26 #include "chrome/browser/download/download_manager.h" |   26 #include "chrome/browser/download/download_manager.h" | 
|   27 #include "chrome/common/chrome_paths.h" |   27 #include "chrome/common/chrome_paths.h" | 
|   28 #include "chrome/common/extensions/extension.h" |   28 #include "chrome/common/extensions/extension.h" | 
|   29 #include "chrome/common/time_format.h" |   29 #include "chrome/common/time_format.h" | 
|   30 #include "gfx/canvas_skia.h" |   30 #include "gfx/canvas.h" | 
|   31 #include "gfx/rect.h" |   31 #include "gfx/rect.h" | 
|   32 #include "grit/generated_resources.h" |   32 #include "grit/generated_resources.h" | 
|   33 #include "grit/locale_settings.h" |   33 #include "grit/locale_settings.h" | 
|   34 #include "grit/theme_resources.h" |   34 #include "grit/theme_resources.h" | 
|   35 #include "net/base/mime_util.h" |   35 #include "net/base/mime_util.h" | 
|   36 #include "skia/ext/image_operations.h" |   36 #include "skia/ext/image_operations.h" | 
|   37 #include "third_party/skia/include/core/SkPath.h" |   37 #include "third_party/skia/include/core/SkPath.h" | 
|   38 #include "third_party/skia/include/core/SkShader.h" |   38 #include "third_party/skia/include/core/SkShader.h" | 
|   39  |   39  | 
|   40 #if defined(TOOLKIT_VIEWS) |   40 #if defined(TOOLKIT_VIEWS) | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  218         SkShader::CreateBitmapShader(*foreground, |  218         SkShader::CreateBitmapShader(*foreground, | 
|  219                                      SkShader::kClamp_TileMode, |  219                                      SkShader::kClamp_TileMode, | 
|  220                                      SkShader::kClamp_TileMode); |  220                                      SkShader::kClamp_TileMode); | 
|  221     SkMatrix shader_scale; |  221     SkMatrix shader_scale; | 
|  222     shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), |  222     shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), | 
|  223                               SkIntToScalar(foreground_bounds.y())); |  223                               SkIntToScalar(foreground_bounds.y())); | 
|  224     shader->setLocalMatrix(shader_scale); |  224     shader->setLocalMatrix(shader_scale); | 
|  225     foreground_paint.setShader(shader); |  225     foreground_paint.setShader(shader); | 
|  226     foreground_paint.setAntiAlias(true); |  226     foreground_paint.setAntiAlias(true); | 
|  227     shader->unref(); |  227     shader->unref(); | 
|  228     canvas->AsCanvasSkia()->drawPath(path, foreground_paint); |  228     canvas->drawPath(path, foreground_paint); | 
|  229     return; |  229     return; | 
|  230   } |  230   } | 
|  231  |  231  | 
|  232   canvas->DrawBitmapInt(*foreground, |  232   canvas->DrawBitmapInt(*foreground, | 
|  233                         foreground_bounds.x(), |  233                         foreground_bounds.x(), | 
|  234                         foreground_bounds.y(), |  234                         foreground_bounds.y(), | 
|  235                         foreground_paint); |  235                         foreground_paint); | 
|  236 } |  236 } | 
|  237  |  237  | 
|  238 void PaintDownloadComplete(gfx::Canvas* canvas, |  238 void PaintDownloadComplete(gfx::Canvas* canvas, | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|  264   // at zero opacity. |  264   // at zero opacity. | 
|  265   static const double PI = 3.141592653589793; |  265   static const double PI = 3.141592653589793; | 
|  266   double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + |  266   double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + | 
|  267                    PI/2) / 2 + 0.5; |  267                    PI/2) / 2 + 0.5; | 
|  268  |  268  | 
|  269   SkRect bounds; |  269   SkRect bounds; | 
|  270   bounds.set(SkIntToScalar(complete_bounds.x()), |  270   bounds.set(SkIntToScalar(complete_bounds.x()), | 
|  271              SkIntToScalar(complete_bounds.y()), |  271              SkIntToScalar(complete_bounds.y()), | 
|  272              SkIntToScalar(complete_bounds.x() + complete_bounds.width()), |  272              SkIntToScalar(complete_bounds.x() + complete_bounds.width()), | 
|  273              SkIntToScalar(complete_bounds.y() + complete_bounds.height())); |  273              SkIntToScalar(complete_bounds.y() + complete_bounds.height())); | 
|  274   canvas->AsCanvasSkia()->saveLayerAlpha( |  274   canvas->saveLayerAlpha(&bounds, | 
|  275       &bounds, |  275                          static_cast<int>(255.0 * opacity), | 
|  276       static_cast<int>(255.0 * opacity), |  276                          SkCanvas::kARGB_ClipLayer_SaveFlag); | 
|  277       SkCanvas::kARGB_ClipLayer_SaveFlag); |  277   canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 
|  278   canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |  | 
|  279   canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); |  278   canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); | 
|  280   canvas->AsCanvasSkia()->restore(); |  279   canvas->restore(); | 
|  281 } |  280 } | 
|  282  |  281  | 
|  283 // Load a language dependent height so that the dangerous download confirmation |  282 // Load a language dependent height so that the dangerous download confirmation | 
|  284 // message doesn't overlap with the download link label. |  283 // message doesn't overlap with the download link label. | 
|  285 int GetBigProgressIconSize() { |  284 int GetBigProgressIconSize() { | 
|  286   static int big_progress_icon_size = 0; |  285   static int big_progress_icon_size = 0; | 
|  287   if (big_progress_icon_size == 0) { |  286   if (big_progress_icon_size == 0) { | 
|  288     string16 locale_size_str = |  287     string16 locale_size_str = | 
|  289         WideToUTF16Hack(l10n_util::GetString(IDS_DOWNLOAD_BIG_PROGRESS_SIZE)); |  288         WideToUTF16Hack(l10n_util::GetString(IDS_DOWNLOAD_BIG_PROGRESS_SIZE)); | 
|  290     bool rc = StringToInt(locale_size_str, &big_progress_icon_size); |  289     bool rc = StringToInt(locale_size_str, &big_progress_icon_size); | 
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  517     AppendNumberToPath(&new_path, count); |  516     AppendNumberToPath(&new_path, count); | 
|  518  |  517  | 
|  519     if (!file_util::PathExists(new_path)) |  518     if (!file_util::PathExists(new_path)) | 
|  520       return count; |  519       return count; | 
|  521   } |  520   } | 
|  522  |  521  | 
|  523   return -1; |  522   return -1; | 
|  524 } |  523 } | 
|  525  |  524  | 
|  526 }  // namespace download_util |  525 }  // namespace download_util | 
| OLD | NEW |