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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Write the manifest. | 146 // Write the manifest. |
147 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); | 147 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); |
148 JSONFileValueSerializer serializer(manifest_path); | 148 JSONFileValueSerializer serializer(manifest_path); |
149 if (!serializer.Serialize(*root)) { | 149 if (!serializer.Serialize(*root)) { |
150 LOG(ERROR) << "Could not serialize manifest."; | 150 LOG(ERROR) << "Could not serialize manifest."; |
151 return NULL; | 151 return NULL; |
152 } | 152 } |
153 | 153 |
154 // Write the icon files. | 154 // Write the icon files. |
155 base::FilePath icons_dir = temp_dir.path().AppendASCII(kIconsDirName); | 155 base::FilePath icons_dir = temp_dir.path().AppendASCII(kIconsDirName); |
156 if (!file_util::CreateDirectory(icons_dir)) { | 156 if (!base::CreateDirectory(icons_dir)) { |
157 LOG(ERROR) << "Could not create icons directory."; | 157 LOG(ERROR) << "Could not create icons directory."; |
158 return NULL; | 158 return NULL; |
159 } | 159 } |
160 for (size_t i = 0; i < web_app.icons.size(); ++i) { | 160 for (size_t i = 0; i < web_app.icons.size(); ++i) { |
161 // Skip unfetched bitmaps. | 161 // Skip unfetched bitmaps. |
162 if (web_app.icons[i].data.config() == SkBitmap::kNo_Config) | 162 if (web_app.icons[i].data.config() == SkBitmap::kNo_Config) |
163 continue; | 163 continue; |
164 | 164 |
165 base::FilePath icon_file = icons_dir.AppendASCII( | 165 base::FilePath icon_file = icons_dir.AppendASCII( |
166 base::StringPrintf("%i.png", web_app.icons[i].width)); | 166 base::StringPrintf("%i.png", web_app.icons[i].width)); |
(...skipping 27 matching lines...) Expand all Loading... |
194 if (!extension.get()) { | 194 if (!extension.get()) { |
195 LOG(ERROR) << error; | 195 LOG(ERROR) << error; |
196 return NULL; | 196 return NULL; |
197 } | 197 } |
198 | 198 |
199 temp_dir.Take(); // The caller takes ownership of the directory. | 199 temp_dir.Take(); // The caller takes ownership of the directory. |
200 return extension; | 200 return extension; |
201 } | 201 } |
202 | 202 |
203 } // namespace extensions | 203 } // namespace extensions |
OLD | NEW |