OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/win/jumplist.h" | 5 #include "chrome/browser/win/jumplist.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 if (!image_skia.isNull()) { | 106 if (!image_skia.isNull()) { |
107 std::vector<float> supported_scales = image_skia.GetSupportedScales(); | 107 std::vector<float> supported_scales = image_skia.GetSupportedScales(); |
108 for (auto& scale : supported_scales) { | 108 for (auto& scale : supported_scales) { |
109 gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale); | 109 gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale); |
110 if (!image_skia_rep.is_null()) | 110 if (!image_skia_rep.is_null()) |
111 image_family.Add( | 111 image_family.Add( |
112 gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap())); | 112 gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap())); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 // If it fails to write the icon's content into the empty temp file just | |
117 // created at |path|, delete the temp file to avoid leakage. | |
116 if (!IconUtil::CreateIconFileFromImageFamily(image_family, path, | 118 if (!IconUtil::CreateIconFileFromImageFamily(image_family, path, |
117 IconUtil::NORMAL_WRITE)) | 119 IconUtil::NORMAL_WRITE)) { |
120 base::DeleteFile(path, false); | |
grt (UTC plus 2)
2017/05/01 08:47:32
nit: put the comment above DeleteFile rather than
chengx
2017/05/01 18:05:47
Done.
| |
118 return false; | 121 return false; |
122 } | |
119 | 123 |
120 // Add this icon file to the list and return its absolute path. | 124 // Add this icon file to the list and return its absolute path. |
121 // The IShellLink::SetIcon() function needs the absolute path to an icon. | 125 // The IShellLink::SetIcon() function needs the absolute path to an icon. |
122 *icon_path = path; | 126 *icon_path = path; |
123 return true; | 127 return true; |
124 } | 128 } |
125 | 129 |
126 // Helper method for RunUpdate to create icon files for the asynchrounously | 130 // Helper method for RunUpdate to create icon files for the asynchrounously |
127 // loaded icons. | 131 // loaded icons. |
128 void CreateIconFiles(const base::FilePath& icon_dir, | 132 void CreateIconFiles(const base::FilePath& icon_dir, |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 705 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
702 } | 706 } |
703 | 707 |
704 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 708 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
705 ChangeReason change_reason) { | 709 ChangeReason change_reason) { |
706 top_sites->GetMostVisitedURLs( | 710 top_sites->GetMostVisitedURLs( |
707 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 711 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
708 weak_ptr_factory_.GetWeakPtr()), | 712 weak_ptr_factory_.GetWeakPtr()), |
709 false); | 713 false); |
710 } | 714 } |
OLD | NEW |