| 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 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| 6 #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 6 #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // as a key to store window location per application URLs in Browser and | 39 // as a key to store window location per application URLs in Browser and |
| 40 // as app id for BrowserWindow, shortcut and jump list. | 40 // as app id for BrowserWindow, shortcut and jump list. |
| 41 std::string GenerateApplicationNameFromURL(const GURL& url); | 41 std::string GenerateApplicationNameFromURL(const GURL& url); |
| 42 | 42 |
| 43 // Compute a deterministic name based on an extension/apps's id. | 43 // Compute a deterministic name based on an extension/apps's id. |
| 44 std::string GenerateApplicationNameFromExtensionId(const std::string& id); | 44 std::string GenerateApplicationNameFromExtensionId(const std::string& id); |
| 45 | 45 |
| 46 // Extracts the extension id from the app name. | 46 // Extracts the extension id from the app name. |
| 47 std::string GetExtensionIdFromApplicationName(const std::string& app_name); | 47 std::string GetExtensionIdFromApplicationName(const std::string& app_name); |
| 48 | 48 |
| 49 // Creates a shortcut for web application based on given shortcut data. | 49 // Creates shortcuts for web application based on given shortcut data. |
| 50 // |profile_path| is the path of the creating profile. |shortcut_info) | 50 // |shortcut_info| contains information about the shortcut to create. |
| 51 // contains information about the shortcut to create. | 51 void CreateShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); |
| 52 void CreateShortcut( | |
| 53 const FilePath& profile_path, | |
| 54 const ShellIntegration::ShortcutInfo& shortcut_info); | |
| 55 | 52 |
| 56 // Delete all the shortcuts that have been created for the extension with | 53 // Delete all the shortcuts that have been created for the given |
| 57 // |extension_id| in the profile with |profile_path|. | 54 // |shortcut_data| in the profile with |profile_path|. |
| 58 void DeleteAllShortcuts(const FilePath& profile_path, | 55 void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); |
| 59 const std::string& extension_id); | |
| 60 | 56 |
| 61 // Creates a shortcut. Must be called on the file thread. This is used to | 57 // Creates a shortcut. Must be called on the file thread. This is used to |
| 62 // implement CreateShortcut() above, and can also be used directly from the | 58 // implement CreateShortcuts() above, and can also be used directly from the |
| 63 // file thread. |profile_path| is the path of the creating profile. | 59 // file thread. |shortcut_info| contains info about the shortcut to create. |
| 64 // |shortcut_info| constains info about the shortcut to create. | 60 bool CreateShortcutsOnFileThread( |
| 65 bool CreateShortcutOnFileThread( | |
| 66 const FilePath& profile_path, | |
| 67 const ShellIntegration::ShortcutInfo& shortcut_info); | 61 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 68 | 62 |
| 69 // Returns true if given url is a valid web app url. | 63 // Returns true if given url is a valid web app url. |
| 70 bool IsValidUrl(const GURL& url); | 64 bool IsValidUrl(const GURL& url); |
| 71 | 65 |
| 72 #if defined(TOOLKIT_VIEWS) | 66 #if defined(TOOLKIT_VIEWS) |
| 73 // Extracts icons info from web app data. Take only square shaped icons and | 67 // Extracts icons info from web app data. Take only square shaped icons and |
| 74 // sort them from smallest to largest. | 68 // sort them from smallest to largest. |
| 75 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; | 69 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; |
| 76 void GetIconsInfo(const WebApplicationInfo& app_info, | 70 void GetIconsInfo(const WebApplicationInfo& app_info, |
| 77 IconInfoList* icons); | 71 IconInfoList* icons); |
| 78 #endif | 72 #endif |
| 79 | 73 |
| 80 #if defined(TOOLKIT_GTK) | 74 #if defined(TOOLKIT_GTK) |
| 81 // GTK+ windows that correspond to web apps need to have a deterministic (and | 75 // GTK+ windows that correspond to web apps need to have a deterministic (and |
| 82 // different) WMClass than normal chrome windows so the window manager groups | 76 // different) WMClass than normal chrome windows so the window manager groups |
| 83 // them as a separate application. | 77 // them as a separate application. |
| 84 std::string GetWMClassFromAppName(std::string app_name); | 78 std::string GetWMClassFromAppName(std::string app_name); |
| 85 #endif | 79 #endif |
| 86 | 80 |
| 87 namespace internals { | 81 namespace internals { |
| 88 | 82 |
| 89 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 90 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); | 84 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); |
| 91 #endif | 85 #endif |
| 92 | 86 |
| 93 // Implemented for each platform, does the platform specific parts of creating | 87 // Implemented for each platform, does the platform specific parts of creating |
| 94 // shortcuts. Used internally by CreateShortcutOnFileThread. | 88 // shortcuts. Used internally by CreateShortcutsOnFileThread. |
| 95 // |shortcut_data_path| is where to store any resources created for the | 89 // |shortcut_data_path| is where to store any resources created for the |
| 96 // shortcut, and is also used as the UserDataDir for platform app shortcuts. | 90 // shortcut, and is also used as the UserDataDir for platform app shortcuts. |
| 97 // |profile_path| is the path of the creating profile. |shortcut_info| | 91 // |shortcut_info| contains info about the shortcut to create. |
| 98 // contains info about the shortcut to create. | 92 bool CreatePlatformShortcuts( |
| 99 bool CreatePlatformShortcut( | |
| 100 const FilePath& shortcut_data_path, | 93 const FilePath& shortcut_data_path, |
| 101 const FilePath& profile_path, | |
| 102 const ShellIntegration::ShortcutInfo& shortcut_info); | 94 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 103 | 95 |
| 104 // Delete all the shortcuts we have added for this extension. This is the | 96 // Delete all the shortcuts we have added for this extension. This is the |
| 105 // platform specific implementation of the DeleteAllShortcuts function, and | 97 // platform specific implementation of the DeleteAllShortcuts function, and |
| 106 // is executed on the FILE thread.. | 98 // is executed on the FILE thread.. |
| 107 void DeletePlatformShortcuts(const FilePath& profile_path, | 99 void DeletePlatformShortcuts( |
| 108 const std::string& extension_id); | 100 const FilePath& shortcut_data_path, |
| 101 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 109 | 102 |
| 110 // Sanitizes |name| and returns a version of it that is safe to use as an | 103 // Sanitizes |name| and returns a version of it that is safe to use as an |
| 111 // on-disk file name . | 104 // on-disk file name . |
| 112 FilePath GetSanitizedFileName(const string16& name); | 105 FilePath GetSanitizedFileName(const string16& name); |
| 113 | 106 |
| 114 } // namespace internals | 107 } // namespace internals |
| 115 | 108 |
| 116 } // namespace web_app | 109 } // namespace web_app |
| 117 | 110 |
| 118 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 111 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| OLD | NEW |