| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/browser_thread.h" | 25 #include "chrome/browser/browser_thread.h" |
| 26 #include "chrome/browser/download/download_util.h" | 26 #include "chrome/browser/download/download_util.h" |
| 27 #include "chrome/browser/profile.h" | 27 #include "chrome/browser/profile.h" |
| 28 #include "chrome/browser/tab_contents/tab_contents.h" | 28 #include "chrome/browser/tab_contents/tab_contents.h" |
| 29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/chrome_plugin_util.h" | 31 #include "chrome/common/chrome_plugin_util.h" |
| 32 #include "chrome/common/notification_registrar.h" | 32 #include "chrome/common/notification_registrar.h" |
| 33 #include "chrome/common/notification_service.h" | 33 #include "chrome/common/notification_service.h" |
| 34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 35 #include "webkit/glue/dom_operations.h" | 35 #include "chrome/common/web_apps.h" |
| 36 | 36 |
| 37 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
| 38 #include "base/environment.h" | 38 #include "base/environment.h" |
| 39 #endif // defined(OS_LINUX) | 39 #endif // defined(OS_LINUX) |
| 40 | 40 |
| 41 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 #include "base/win_util.h" | 42 #include "base/win_util.h" |
| 43 #include "gfx/icon_util.h" | 43 #include "gfx/icon_util.h" |
| 44 #endif // defined(OS_WIN) | 44 #endif // defined(OS_WIN) |
| 45 | 45 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Returns data directory for given web app url | 109 // Returns data directory for given web app url |
| 110 FilePath GetWebAppDataDirectory(const FilePath& root_dir, | 110 FilePath GetWebAppDataDirectory(const FilePath& root_dir, |
| 111 const GURL& url) { | 111 const GURL& url) { |
| 112 return root_dir.Append(GetWebAppDir(url)); | 112 return root_dir.Append(GetWebAppDir(url)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 #if defined(TOOLKIT_VIEWS) | 115 #if defined(TOOLKIT_VIEWS) |
| 116 // Predicator for sorting images from largest to smallest. | 116 // Predicator for sorting images from largest to smallest. |
| 117 bool IconPrecedes( | 117 bool IconPrecedes(const WebApplicationInfo::IconInfo& left, |
| 118 const webkit_glue::WebApplicationInfo::IconInfo& left, | 118 const WebApplicationInfo::IconInfo& right) { |
| 119 const webkit_glue::WebApplicationInfo::IconInfo& right) { | |
| 120 return left.width < right.width; | 119 return left.width < right.width; |
| 121 } | 120 } |
| 122 #endif | 121 #endif |
| 123 | 122 |
| 124 #if defined(OS_WIN) | 123 #if defined(OS_WIN) |
| 125 // Calculates image checksum using MD5. | 124 // Calculates image checksum using MD5. |
| 126 void GetImageCheckSum(const SkBitmap& image, MD5Digest* digest) { | 125 void GetImageCheckSum(const SkBitmap& image, MD5Digest* digest) { |
| 127 DCHECK(digest); | 126 DCHECK(digest); |
| 128 | 127 |
| 129 SkAutoLockPixels image_lock(image); | 128 SkAutoLockPixels image_lock(image); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 715 } |
| 717 | 716 |
| 718 return false; | 717 return false; |
| 719 } | 718 } |
| 720 | 719 |
| 721 FilePath GetDataDir(const FilePath& profile_path) { | 720 FilePath GetDataDir(const FilePath& profile_path) { |
| 722 return profile_path.Append(chrome::kWebAppDirname); | 721 return profile_path.Append(chrome::kWebAppDirname); |
| 723 } | 722 } |
| 724 | 723 |
| 725 #if defined(TOOLKIT_VIEWS) | 724 #if defined(TOOLKIT_VIEWS) |
| 726 void GetIconsInfo(const webkit_glue::WebApplicationInfo& app_info, | 725 void GetIconsInfo(const WebApplicationInfo& app_info, |
| 727 IconInfoList* icons) { | 726 IconInfoList* icons) { |
| 728 DCHECK(icons); | 727 DCHECK(icons); |
| 729 | 728 |
| 730 icons->clear(); | 729 icons->clear(); |
| 731 for (size_t i = 0; i < app_info.icons.size(); ++i) { | 730 for (size_t i = 0; i < app_info.icons.size(); ++i) { |
| 732 // We only take square shaped icons (i.e. width == height). | 731 // We only take square shaped icons (i.e. width == height). |
| 733 if (app_info.icons[i].width == app_info.icons[i].height) { | 732 if (app_info.icons[i].width == app_info.icons[i].height) { |
| 734 icons->push_back(app_info.icons[i]); | 733 icons->push_back(app_info.icons[i]); |
| 735 } | 734 } |
| 736 } | 735 } |
| 737 | 736 |
| 738 std::sort(icons->begin(), icons->end(), &IconPrecedes); | 737 std::sort(icons->begin(), icons->end(), &IconPrecedes); |
| 739 } | 738 } |
| 740 #endif | 739 #endif |
| 741 | 740 |
| 742 void GetShortcutInfoForTab(TabContents* tab_contents, | 741 void GetShortcutInfoForTab(TabContents* tab_contents, |
| 743 ShellIntegration::ShortcutInfo* info) { | 742 ShellIntegration::ShortcutInfo* info) { |
| 744 DCHECK(info); // Must provide a valid info. | 743 DCHECK(info); // Must provide a valid info. |
| 745 | 744 |
| 746 const webkit_glue::WebApplicationInfo& app_info = | 745 const WebApplicationInfo& app_info = tab_contents->web_app_info(); |
| 747 tab_contents->web_app_info(); | |
| 748 | 746 |
| 749 info->url = app_info.app_url.is_empty() ? tab_contents->GetURL() : | 747 info->url = app_info.app_url.is_empty() ? tab_contents->GetURL() : |
| 750 app_info.app_url; | 748 app_info.app_url; |
| 751 info->title = app_info.title.empty() ? | 749 info->title = app_info.title.empty() ? |
| 752 (tab_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : | 750 (tab_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : |
| 753 tab_contents->GetTitle()) : | 751 tab_contents->GetTitle()) : |
| 754 app_info.title; | 752 app_info.title; |
| 755 info->description = app_info.description; | 753 info->description = app_info.description; |
| 756 info->favicon = tab_contents->GetFavIcon(); | 754 info->favicon = tab_contents->GetFavIcon(); |
| 757 } | 755 } |
| 758 | 756 |
| 759 void UpdateShortcutForTabContents(TabContents* tab_contents) { | 757 void UpdateShortcutForTabContents(TabContents* tab_contents) { |
| 760 #if defined(OS_WIN) | 758 #if defined(OS_WIN) |
| 761 // UpdateShortcutWorker will delete itself when it's done. | 759 // UpdateShortcutWorker will delete itself when it's done. |
| 762 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 760 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 763 worker->Run(); | 761 worker->Run(); |
| 764 #endif // defined(OS_WIN) | 762 #endif // defined(OS_WIN) |
| 765 } | 763 } |
| 766 | 764 |
| 767 }; // namespace web_app | 765 }; // namespace web_app |
| OLD | NEW |