| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 return FilePath(host).Append(scheme_port); | 105 return FilePath(host).Append(scheme_port); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Returns data directory for given web app url | 108 // Returns data directory for given web app url |
| 109 FilePath GetWebAppDataDirectory(const FilePath& root_dir, | 109 FilePath GetWebAppDataDirectory(const FilePath& root_dir, |
| 110 const GURL& url) { | 110 const GURL& url) { |
| 111 return root_dir.Append(GetWebAppDir(url)); | 111 return root_dir.Append(GetWebAppDir(url)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 #if defined(TOOLKIT_VIEWS) |
| 114 // Predicator for sorting images from largest to smallest. | 115 // Predicator for sorting images from largest to smallest. |
| 115 bool IconPrecedes( | 116 bool IconPrecedes( |
| 116 const webkit_glue::WebApplicationInfo::IconInfo& left, | 117 const webkit_glue::WebApplicationInfo::IconInfo& left, |
| 117 const webkit_glue::WebApplicationInfo::IconInfo& right) { | 118 const webkit_glue::WebApplicationInfo::IconInfo& right) { |
| 118 return left.width < right.width; | 119 return left.width < right.width; |
| 119 } | 120 } |
| 121 #endif |
| 120 | 122 |
| 123 #if defined(OS_WIN) |
| 121 // Calculates image checksum using MD5. | 124 // Calculates image checksum using MD5. |
| 122 void GetImageCheckSum(const SkBitmap& image, MD5Digest* digest) { | 125 void GetImageCheckSum(const SkBitmap& image, MD5Digest* digest) { |
| 123 DCHECK(digest); | 126 DCHECK(digest); |
| 124 | 127 |
| 125 SkAutoLockPixels image_lock(image); | 128 SkAutoLockPixels image_lock(image); |
| 126 MD5Sum(image.getPixels(), image.getSize(), digest); | 129 MD5Sum(image.getPixels(), image.getSize(), digest); |
| 127 } | 130 } |
| 128 | 131 |
| 129 #if defined(OS_WIN) | |
| 130 // Saves |image| as an |icon_file| with the checksum. | 132 // Saves |image| as an |icon_file| with the checksum. |
| 131 bool SaveIconWithCheckSum(const FilePath& icon_file, const SkBitmap& image) { | 133 bool SaveIconWithCheckSum(const FilePath& icon_file, const SkBitmap& image) { |
| 132 if (!IconUtil::CreateIconFileFromSkBitmap(image, icon_file)) | 134 if (!IconUtil::CreateIconFileFromSkBitmap(image, icon_file)) |
| 133 return false; | 135 return false; |
| 134 | 136 |
| 135 MD5Digest digest; | 137 MD5Digest digest; |
| 136 GetImageCheckSum(image, &digest); | 138 GetImageCheckSum(image, &digest); |
| 137 | 139 |
| 138 FilePath cheksum_file(icon_file.ReplaceExtension(kIconChecksumFileExt)); | 140 FilePath cheksum_file(icon_file.ReplaceExtension(kIconChecksumFileExt)); |
| 139 return file_util::WriteFile(cheksum_file, | 141 return file_util::WriteFile(cheksum_file, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 | 757 |
| 756 void UpdateShortcutForTabContents(TabContents* tab_contents) { | 758 void UpdateShortcutForTabContents(TabContents* tab_contents) { |
| 757 #if defined(OS_WIN) | 759 #if defined(OS_WIN) |
| 758 // UpdateShortcutWorker will delete itself when it's done. | 760 // UpdateShortcutWorker will delete itself when it's done. |
| 759 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 761 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 760 worker->Run(); | 762 worker->Run(); |
| 761 #endif // defined(OS_WIN) | 763 #endif // defined(OS_WIN) |
| 762 } | 764 } |
| 763 | 765 |
| 764 }; // namespace web_app | 766 }; // namespace web_app |
| OLD | NEW |