Chromium Code Reviews| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 // as app id for BrowserWindow, shortcut and jump list. | 39 // as app id for BrowserWindow, shortcut and jump list. |
| 40 std::string GenerateApplicationNameFromURL(const GURL& url); | 40 std::string GenerateApplicationNameFromURL(const GURL& url); |
| 41 | 41 |
| 42 // Compute a deterministic name based on an extension/apps's id. | 42 // Compute a deterministic name based on an extension/apps's id. |
| 43 std::string GenerateApplicationNameFromExtensionId(const std::string& id); | 43 std::string GenerateApplicationNameFromExtensionId(const std::string& id); |
| 44 | 44 |
| 45 // Extracts the extension id from the app name. | 45 // Extracts the extension id from the app name. |
| 46 std::string GetExtensionIdFromApplicationName(const std::string& app_name); | 46 std::string GetExtensionIdFromApplicationName(const std::string& app_name); |
| 47 | 47 |
| 48 // Creates a shortcut for web application based on given shortcut data. | 48 // Creates a shortcut for web application based on given shortcut data. |
| 49 // |profile_path| is used as root directory for persisted data such as icon. | 49 // |profile_path| is the path of the creating profile. |shortcut_info) |
| 50 // Directory layout is similar to what Gears has, i.e. an web application's | 50 // contains information about the shortcut to create. |
| 51 // file is stored under "#/host_name/scheme_port", where '#' is the | |
| 52 // |root_dir|. A crx based app uses a directory named _crx_<app id>. | |
| 53 void CreateShortcut( | 51 void CreateShortcut( |
| 54 const FilePath& profile_path, | 52 const FilePath& profile_path, |
| 55 const ShellIntegration::ShortcutInfo& shortcut_info); | 53 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 56 | 54 |
| 55 // Creates a shortcut. Must be called on the file thread. This is used to | |
| 56 // implement CreateShortcut() above, and can also be used directly from the | |
| 57 // file thread. |profile_path| is the path of the creating profile. | |
| 58 // |shortcut_info| constains info about the shortcut to create. | |
| 59 bool CreateShortcutOnFileThread( | |
| 60 const FilePath& profile_path, | |
|
sail
2012/04/12 15:06:29
do you really need this? if you just call CreateSh
benwells
2012/04/13 01:48:48
This function returns success or failure, which th
sail
2012/04/13 01:59:14
what's the point of returning failure?
putting up
benwells
2012/04/13 02:09:02
In the NTP there is a command to create the shortc
sail
2012/04/13 02:16:41
ok
| |
| 61 const ShellIntegration::ShortcutInfo& shortcut_info); | |
| 62 | |
| 57 // Returns true if given url is a valid web app url. | 63 // Returns true if given url is a valid web app url. |
| 58 bool IsValidUrl(const GURL& url); | 64 bool IsValidUrl(const GURL& url); |
| 59 | 65 |
| 60 #if defined(TOOLKIT_VIEWS) | 66 #if defined(TOOLKIT_VIEWS) |
| 61 // 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 |
| 62 // sort them from smallest to largest. | 68 // sort them from smallest to largest. |
| 63 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; | 69 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; |
| 64 void GetIconsInfo(const WebApplicationInfo& app_info, | 70 void GetIconsInfo(const WebApplicationInfo& app_info, |
| 65 IconInfoList* icons); | 71 IconInfoList* icons); |
| 66 #endif | 72 #endif |
| 67 | 73 |
| 68 #if defined(TOOLKIT_USES_GTK) | 74 #if defined(TOOLKIT_USES_GTK) |
| 69 // 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 |
| 70 // different) WMClass than normal chrome windows so the window manager groups | 76 // different) WMClass than normal chrome windows so the window manager groups |
| 71 // them as a separate application. | 77 // them as a separate application. |
| 72 std::string GetWMClassFromAppName(std::string app_name); | 78 std::string GetWMClassFromAppName(std::string app_name); |
| 73 #endif | 79 #endif |
| 74 | 80 |
| 75 namespace internals { | 81 namespace internals { |
| 76 | 82 |
| 77 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 78 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); | 84 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); |
| 79 #endif | 85 #endif |
| 80 | 86 |
| 81 // Does the actual job of creating a shortcut (see CreateShortcut() above). | 87 // Implemented for each platform, does the platform specific parts of creating |
| 82 // This must be called on the file thread. | 88 // shortcuts. Used internally by CreateShortcutOnFileThread. |
| 83 void CreateShortcutTask(const FilePath& web_app_path, | 89 // |shortcut_data_path| is where to store any resources created for the |
| 84 const FilePath& profile_path, | 90 // shortcut, and is also used as the UserDataDir for platform app shortcuts. |
| 85 const ShellIntegration::ShortcutInfo& shortcut_info); | 91 // |profile_path| is the path of the creating profile. |shortcut_info| |
| 92 // contains info about the shortcut to create. | |
| 93 bool CreatePlatformShortcut( | |
| 94 const FilePath& shortcut_data_path, | |
| 95 const FilePath& profile_path, | |
| 96 const ShellIntegration::ShortcutInfo& shortcut_info); | |
| 86 | 97 |
| 87 // Sanitizes |name| and returns a version of it that is safe to use as an | 98 // Sanitizes |name| and returns a version of it that is safe to use as an |
| 88 // on-disk file name . | 99 // on-disk file name . |
| 89 FilePath GetSanitizedFileName(const string16& name); | 100 FilePath GetSanitizedFileName(const string16& name); |
| 90 | 101 |
| 91 } // namespace internals | 102 } // namespace internals |
| 92 | 103 |
| 93 } // namespace web_app | 104 } // namespace web_app |
| 94 | 105 |
| 95 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 106 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| OLD | NEW |