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 "chrome/browser/extensions/convert_web_app.h" | 5 #include "chrome/browser/extensions/convert_web_app.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 // Write the icon files. | 129 // Write the icon files. |
130 base::FilePath icons_dir = temp_dir.path().AppendASCII(kIconsDirName); | 130 base::FilePath icons_dir = temp_dir.path().AppendASCII(kIconsDirName); |
131 if (!base::CreateDirectory(icons_dir)) { | 131 if (!base::CreateDirectory(icons_dir)) { |
132 LOG(ERROR) << "Could not create icons directory."; | 132 LOG(ERROR) << "Could not create icons directory."; |
133 return NULL; | 133 return NULL; |
134 } | 134 } |
135 for (size_t i = 0; i < web_app.icons.size(); ++i) { | 135 for (size_t i = 0; i < web_app.icons.size(); ++i) { |
136 // Skip unfetched bitmaps. | 136 // Skip unfetched bitmaps. |
137 if (web_app.icons[i].data.config() == SkBitmap::kNo_Config) | 137 if (web_app.icons[i].data.colorType() == kUnknown_SkColorType) |
138 continue; | 138 continue; |
139 | 139 |
140 base::FilePath icon_file = icons_dir.AppendASCII( | 140 base::FilePath icon_file = icons_dir.AppendASCII( |
141 base::StringPrintf("%i.png", web_app.icons[i].width)); | 141 base::StringPrintf("%i.png", web_app.icons[i].width)); |
142 std::vector<unsigned char> image_data; | 142 std::vector<unsigned char> image_data; |
143 if (!gfx::PNGCodec::EncodeBGRASkBitmap(web_app.icons[i].data, | 143 if (!gfx::PNGCodec::EncodeBGRASkBitmap(web_app.icons[i].data, |
144 false, | 144 false, |
145 &image_data)) { | 145 &image_data)) { |
146 LOG(ERROR) << "Could not create icon file."; | 146 LOG(ERROR) << "Could not create icon file."; |
147 return NULL; | 147 return NULL; |
(...skipping 18 matching lines...) Expand all Loading... |
166 if (!extension.get()) { | 166 if (!extension.get()) { |
167 LOG(ERROR) << error; | 167 LOG(ERROR) << error; |
168 return NULL; | 168 return NULL; |
169 } | 169 } |
170 | 170 |
171 temp_dir.Take(); // The caller takes ownership of the directory. | 171 temp_dir.Take(); // The caller takes ownership of the directory. |
172 return extension; | 172 return extension; |
173 } | 173 } |
174 | 174 |
175 } // namespace extensions | 175 } // namespace extensions |
OLD | NEW |