+bool GenerateDefaultIcon(const bf::path& icon_path,
+ application_x* app, bool make_copy) {
+ bs::error_code error;
+ if (make_copy) {
+ bf::copy_file(kDefaultIconPath, icon_path,
+ bf::copy_option::overwrite_if_exists, error);
+ if (error) {
+ LOG(ERROR) << "Failed to create default icon for web application";
+ return false;
+ }
+ } else {
+ if (!bf::exists(icon_path)) {
+ LOG(ERROR) << "Can't find icon in " << icon_path;
+ return false;
+ }
+ }
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ if (!icon) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+ icon->text = strdup(icon_path.c_str());
+ icon->lang = strdup(DEFAULT_LOCALE);
+ app->icon = g_list_append(app->icon, icon);
+
+ return true;
+}
+