| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Generates app id from web app url and profile path. | 251 // Generates app id from web app url and profile path. |
| 252 string16 app_id = ShellIntegration::GetAppModelIdForProfile( | 252 string16 app_id = ShellIntegration::GetAppModelIdForProfile( |
| 253 UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), | 253 UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), |
| 254 profile_path_); | 254 profile_path_); |
| 255 | 255 |
| 256 // Sanitize description | 256 // Sanitize description |
| 257 if (shortcut_info_.description.length() >= MAX_PATH) | 257 if (shortcut_info_.description.length() >= MAX_PATH) |
| 258 shortcut_info_.description.resize(MAX_PATH - 1); | 258 shortcut_info_.description.resize(MAX_PATH - 1); |
| 259 | 259 |
| 260 for (size_t i = 0; i < shortcut_files_.size(); ++i) { | 260 for (size_t i = 0; i < shortcut_files_.size(); ++i) { |
| 261 file_util::ShortcutProperties shortcut_properties; |
| 262 shortcut_properties.set_target(shortcut_files_[i].value()); |
| 263 shortcut_properties.set_description(shortcut_info_.description.c_str()); |
| 264 shortcut_properties.set_icon(icon_file.value(), 0); |
| 265 shortcut_properties.set_app_id(app_id); |
| 261 file_util::CreateOrUpdateShortcutLink( | 266 file_util::CreateOrUpdateShortcutLink( |
| 262 NULL, | |
| 263 shortcut_files_[i].value().c_str(), | 267 shortcut_files_[i].value().c_str(), |
| 264 NULL, | 268 shortcut_properties, |
| 265 NULL, | 269 file_util::SHORTCUT_UPDATE_EXISTING); |
| 266 shortcut_info_.description.c_str(), | |
| 267 icon_file.value().c_str(), | |
| 268 0, | |
| 269 app_id.c_str(), | |
| 270 file_util::SHORTCUT_NO_OPTIONS); | |
| 271 } | 270 } |
| 272 } | 271 } |
| 273 | 272 |
| 274 OnShortcutsUpdated(true); | 273 OnShortcutsUpdated(true); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void UpdateShortcutWorker::OnShortcutsUpdated(bool) { | 276 void UpdateShortcutWorker::OnShortcutsUpdated(bool) { |
| 278 DeleteMe(); // We are done. | 277 DeleteMe(); // We are done. |
| 279 } | 278 } |
| 280 | 279 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 320 |
| 322 void UpdateShortcutForTabContents(TabContents* tab_contents) { | 321 void UpdateShortcutForTabContents(TabContents* tab_contents) { |
| 323 #if defined(OS_WIN) | 322 #if defined(OS_WIN) |
| 324 // UpdateShortcutWorker will delete itself when it's done. | 323 // UpdateShortcutWorker will delete itself when it's done. |
| 325 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 324 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 326 worker->Run(); | 325 worker->Run(); |
| 327 #endif // defined(OS_WIN) | 326 #endif // defined(OS_WIN) |
| 328 } | 327 } |
| 329 | 328 |
| 330 } // namespace web_app | 329 } // namespace web_app |
| OLD | NEW |