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/ui/web_applications/web_app_ui.h" | 5 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 base::FilePath icon_file = web_app_path.Append(file_name_).ReplaceExtension( | 276 base::FilePath icon_file = web_app_path.Append(file_name_).ReplaceExtension( |
277 FILE_PATH_LITERAL(".ico")); | 277 FILE_PATH_LITERAL(".ico")); |
278 web_app::internals::CheckAndSaveIcon(icon_file, | 278 web_app::internals::CheckAndSaveIcon(icon_file, |
279 *shortcut_info_.favicon.ToSkBitmap()); | 279 *shortcut_info_.favicon.ToSkBitmap()); |
280 | 280 |
281 // Update existing shortcuts' description, icon and app id. | 281 // Update existing shortcuts' description, icon and app id. |
282 CheckExistingShortcuts(); | 282 CheckExistingShortcuts(); |
283 if (!shortcut_files_.empty()) { | 283 if (!shortcut_files_.empty()) { |
284 // Generates app id from web app url and profile path. | 284 // Generates app id from web app url and profile path. |
285 string16 app_id = ShellIntegration::GetAppModelIdForProfile( | 285 string16 app_id = ShellIntegration::GetAppModelIdForProfile( |
286 base::UTF8ToWide(web_app::GenerateApplicationNameFromURL( | 286 UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), |
287 shortcut_info_.url)), | |
288 profile_path_); | 287 profile_path_); |
289 | 288 |
290 // Sanitize description | 289 // Sanitize description |
291 if (shortcut_info_.description.length() >= MAX_PATH) | 290 if (shortcut_info_.description.length() >= MAX_PATH) |
292 shortcut_info_.description.resize(MAX_PATH - 1); | 291 shortcut_info_.description.resize(MAX_PATH - 1); |
293 | 292 |
294 for (size_t i = 0; i < shortcut_files_.size(); ++i) { | 293 for (size_t i = 0; i < shortcut_files_.size(); ++i) { |
295 base::win::ShortcutProperties shortcut_properties; | 294 base::win::ShortcutProperties shortcut_properties; |
296 shortcut_properties.set_target(shortcut_files_[i]); | 295 shortcut_properties.set_target(shortcut_files_[i]); |
297 shortcut_properties.set_description(shortcut_info_.description); | 296 shortcut_properties.set_description(shortcut_info_.description); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 445 } |
447 | 446 |
448 // |info_list| may still be empty at this point, in which case LoadImage | 447 // |info_list| may still be empty at this point, in which case LoadImage |
449 // will call the OnImageLoaded callback with an empty image and exit | 448 // will call the OnImageLoaded callback with an empty image and exit |
450 // immediately. | 449 // immediately. |
451 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, | 450 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, |
452 base::Bind(&OnImageLoaded, shortcut_info, callback)); | 451 base::Bind(&OnImageLoaded, shortcut_info, callback)); |
453 } | 452 } |
454 | 453 |
455 } // namespace web_app | 454 } // namespace web_app |
OLD | NEW |