| 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/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return web_app::GetWebAppDataDirectory(shortcut_info.profile_path, | 85 return web_app::GetWebAppDataDirectory(shortcut_info.profile_path, |
| 86 shortcut_info.extension_id, | 86 shortcut_info.extension_id, |
| 87 shortcut_info.url); | 87 shortcut_info.url); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void UpdateAllShortcutsForShortcutInfo( | 90 void UpdateAllShortcutsForShortcutInfo( |
| 91 const base::string16& old_app_title, | 91 const base::string16& old_app_title, |
| 92 const base::Closure& callback, | 92 const base::Closure& callback, |
| 93 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { | 93 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { |
| 94 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); | 94 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); |
| 95 shortcut_info->favicon.DetachFromThread(); |
| 95 web_app::ShortcutInfo::PostIOTaskAndReply( | 96 web_app::ShortcutInfo::PostIOTaskAndReply( |
| 96 base::BindOnce(&web_app::internals::UpdatePlatformShortcuts, | 97 base::BindOnce(&web_app::internals::UpdatePlatformShortcuts, |
| 97 shortcut_data_dir, old_app_title), | 98 shortcut_data_dir, old_app_title), |
| 98 std::move(shortcut_info), callback); | 99 std::move(shortcut_info), callback); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void OnImageLoaded(std::unique_ptr<web_app::ShortcutInfo> shortcut_info, | 102 void OnImageLoaded(std::unique_ptr<web_app::ShortcutInfo> shortcut_info, |
| 102 web_app::ShortcutInfoCallback callback, | 103 web_app::ShortcutInfoCallback callback, |
| 103 const gfx::ImageFamily& image_family) { | 104 const gfx::ImageFamily& image_family) { |
| 104 // If the image failed to load (e.g. if the resource being loaded was empty) | 105 // If the image failed to load (e.g. if the resource being loaded was empty) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 120 } | 121 } |
| 121 | 122 |
| 122 callback.Run(std::move(shortcut_info)); | 123 callback.Run(std::move(shortcut_info)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void ScheduleCreatePlatformShortcut( | 126 void ScheduleCreatePlatformShortcut( |
| 126 web_app::ShortcutCreationReason reason, | 127 web_app::ShortcutCreationReason reason, |
| 127 const web_app::ShortcutLocations& locations, | 128 const web_app::ShortcutLocations& locations, |
| 128 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { | 129 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { |
| 129 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); | 130 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); |
| 131 shortcut_info->favicon.DetachFromThread(); |
| 130 web_app::ShortcutInfo::PostIOTask( | 132 web_app::ShortcutInfo::PostIOTask( |
| 131 base::BindOnce( | 133 base::BindOnce( |
| 132 base::IgnoreResult(&web_app::internals::CreatePlatformShortcuts), | 134 base::IgnoreResult(&web_app::internals::CreatePlatformShortcuts), |
| 133 shortcut_data_dir, locations, reason), | 135 shortcut_data_dir, locations, reason), |
| 134 std::move(shortcut_info)); | 136 std::move(shortcut_info)); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void DeleteShortcutInfoOnUIThread( | 139 void DeleteShortcutInfoOnUIThread( |
| 138 std::unique_ptr<web_app::ShortcutInfo> shortcut_info, | 140 std::unique_ptr<web_app::ShortcutInfo> shortcut_info, |
| 139 base::OnceClosure callback) { | 141 base::OnceClosure callback) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 532 |
| 531 #if defined(OS_LINUX) | 533 #if defined(OS_LINUX) |
| 532 std::string GetWMClassFromAppName(std::string app_name) { | 534 std::string GetWMClassFromAppName(std::string app_name) { |
| 533 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); | 535 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 534 base::TrimString(app_name, "_", &app_name); | 536 base::TrimString(app_name, "_", &app_name); |
| 535 return app_name; | 537 return app_name; |
| 536 } | 538 } |
| 537 #endif | 539 #endif |
| 538 | 540 |
| 539 } // namespace web_app | 541 } // namespace web_app |
| OLD | NEW |