| 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" |
| 11 #include "base/string16.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 #include "chrome/browser/extensions/extension_tab_helper.h" | 14 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 17 #include "chrome/browser/web_applications/web_app.h" | 18 #include "chrome/browser/web_applications/web_app.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 242 |
| 242 FilePath icon_file = web_app_path.Append(file_name_).ReplaceExtension( | 243 FilePath icon_file = web_app_path.Append(file_name_).ReplaceExtension( |
| 243 FILE_PATH_LITERAL(".ico")); | 244 FILE_PATH_LITERAL(".ico")); |
| 244 web_app::internals::CheckAndSaveIcon(icon_file, | 245 web_app::internals::CheckAndSaveIcon(icon_file, |
| 245 *shortcut_info_.favicon.ToSkBitmap()); | 246 *shortcut_info_.favicon.ToSkBitmap()); |
| 246 | 247 |
| 247 // Update existing shortcuts' description, icon and app id. | 248 // Update existing shortcuts' description, icon and app id. |
| 248 CheckExistingShortcuts(); | 249 CheckExistingShortcuts(); |
| 249 if (!shortcut_files_.empty()) { | 250 if (!shortcut_files_.empty()) { |
| 250 // Generates app id from web app url and profile path. | 251 // Generates app id from web app url and profile path. |
| 251 std::wstring app_id = ShellIntegration::GetAppId( | 252 string16 app_id = ShellIntegration::GetAppModelIdForProfile( |
| 252 UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), | 253 UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), |
| 253 profile_path_); | 254 profile_path_); |
| 254 | 255 |
| 255 // Sanitize description | 256 // Sanitize description |
| 256 if (shortcut_info_.description.length() >= MAX_PATH) | 257 if (shortcut_info_.description.length() >= MAX_PATH) |
| 257 shortcut_info_.description.resize(MAX_PATH - 1); | 258 shortcut_info_.description.resize(MAX_PATH - 1); |
| 258 | 259 |
| 259 for (size_t i = 0; i < shortcut_files_.size(); ++i) { | 260 for (size_t i = 0; i < shortcut_files_.size(); ++i) { |
| 260 file_util::CreateOrUpdateShortcutLink( | 261 file_util::CreateOrUpdateShortcutLink( |
| 261 NULL, | 262 NULL, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 319 |
| 319 void UpdateShortcutForTabContents(TabContents* tab_contents) { | 320 void UpdateShortcutForTabContents(TabContents* tab_contents) { |
| 320 #if defined(OS_WIN) | 321 #if defined(OS_WIN) |
| 321 // UpdateShortcutWorker will delete itself when it's done. | 322 // UpdateShortcutWorker will delete itself when it's done. |
| 322 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 323 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 323 worker->Run(); | 324 worker->Run(); |
| 324 #endif // defined(OS_WIN) | 325 #endif // defined(OS_WIN) |
| 325 } | 326 } |
| 326 | 327 |
| 327 } // namespace web_app | 328 } // namespace web_app |
| OLD | NEW |