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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return base::StringPrintf("%i.%i.%i.%i", | 79 return base::StringPrintf("%i.%i.%i.%i", |
80 create_time_exploded.year, | 80 create_time_exploded.year, |
81 create_time_exploded.month, | 81 create_time_exploded.month, |
82 create_time_exploded.day_of_month, | 82 create_time_exploded.day_of_month, |
83 static_cast<uint16>(stamp)); | 83 static_cast<uint16>(stamp)); |
84 } | 84 } |
85 | 85 |
86 scoped_refptr<Extension> ConvertWebAppToExtension( | 86 scoped_refptr<Extension> ConvertWebAppToExtension( |
87 const WebApplicationInfo& web_app, | 87 const WebApplicationInfo& web_app, |
88 const Time& create_time, | 88 const Time& create_time, |
| 89 int creation_flags, |
89 const base::FilePath& extensions_dir) { | 90 const base::FilePath& extensions_dir) { |
90 base::FilePath install_temp_dir = | 91 base::FilePath install_temp_dir = |
91 file_util::GetInstallTempDir(extensions_dir); | 92 file_util::GetInstallTempDir(extensions_dir); |
92 if (install_temp_dir.empty()) { | 93 if (install_temp_dir.empty()) { |
93 LOG(ERROR) << "Could not get path to profile temporary directory."; | 94 LOG(ERROR) << "Could not get path to profile temporary directory."; |
94 return NULL; | 95 return NULL; |
95 } | 96 } |
96 | 97 |
97 base::ScopedTempDir temp_dir; | 98 base::ScopedTempDir temp_dir; |
98 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { | 99 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 int size = base::checked_cast<int>(image_data.size()); | 152 int size = base::checked_cast<int>(image_data.size()); |
152 if (base::WriteFile(icon_file, image_data_ptr, size) != size) { | 153 if (base::WriteFile(icon_file, image_data_ptr, size) != size) { |
153 LOG(ERROR) << "Could not write icon file."; | 154 LOG(ERROR) << "Could not write icon file."; |
154 return NULL; | 155 return NULL; |
155 } | 156 } |
156 } | 157 } |
157 | 158 |
158 // Finally, create the extension object to represent the unpacked directory. | 159 // Finally, create the extension object to represent the unpacked directory. |
159 std::string error; | 160 std::string error; |
160 scoped_refptr<Extension> extension = Extension::Create( | 161 scoped_refptr<Extension> extension = Extension::Create( |
161 temp_dir.path(), | 162 temp_dir.path(), Manifest::INTERNAL, *root, creation_flags, &error); |
162 Manifest::INTERNAL, | |
163 *root, | |
164 Extension::FROM_BOOKMARK, | |
165 &error); | |
166 if (!extension.get()) { | 163 if (!extension.get()) { |
167 LOG(ERROR) << error; | 164 LOG(ERROR) << error; |
168 return NULL; | 165 return NULL; |
169 } | 166 } |
170 | 167 |
171 temp_dir.Take(); // The caller takes ownership of the directory. | 168 temp_dir.Take(); // The caller takes ownership of the directory. |
172 return extension; | 169 return extension; |
173 } | 170 } |
174 | 171 |
175 } // namespace extensions | 172 } // namespace extensions |
OLD | NEW |