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> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/shell_integration.h" | 14 #include "chrome/browser/shell_integration.h" |
| 15 #include "chrome/common/web_apps.h" | 15 #include "chrome/common/web_apps.h" |
| 16 | 16 |
| 17 class Extension; | |
| 18 | |
| 17 namespace web_app { | 19 namespace web_app { |
| 18 | 20 |
| 21 // Returns data directory for given web app url. | |
| 22 FilePath GetWebAppDataDirectory(const FilePath& profile_path, | |
| 23 const std::string& extension_id, | |
|
Mihai Parparita -not on Chrome
2012/02/21 20:53:21
Rather than the two overloaded variants of GetWebA
sail
2012/02/22 22:10:08
I added a comment explaining how |extension_id| an
| |
| 24 const GURL& url); | |
| 25 | |
| 26 // Gets the user data directory to use for |extension| located inside the | |
| 27 // directory for |profile|. | |
|
Mihai Parparita -not on Chrome
2012/02/21 20:53:21
Nit: Should this be |profile_path| instead?
sail
2012/02/22 22:10:08
Done.
| |
| 28 FilePath GetWebAppDataDirectory(const FilePath& profile_path, | |
| 29 const Extension& extension); | |
| 30 | |
| 19 // Compute a deterministic name based on data in the shortcut_info. | 31 // Compute a deterministic name based on data in the shortcut_info. |
| 20 std::string GenerateApplicationNameFromInfo( | 32 std::string GenerateApplicationNameFromInfo( |
| 21 const ShellIntegration::ShortcutInfo& shortcut_info); | 33 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 22 | 34 |
| 23 // Compute a deterministic name based on the URL. We use this pseudo name | 35 // Compute a deterministic name based on the URL. We use this pseudo name |
| 24 // as a key to store window location per application URLs in Browser and | 36 // as a key to store window location per application URLs in Browser and |
| 25 // as app id for BrowserWindow, shortcut and jump list. | 37 // as app id for BrowserWindow, shortcut and jump list. |
| 26 std::string GenerateApplicationNameFromURL(const GURL& url); | 38 std::string GenerateApplicationNameFromURL(const GURL& url); |
| 27 | 39 |
| 28 // Compute a deterministic name based on an extension/apps's id. | 40 // Compute a deterministic name based on an extension/apps's id. |
| 29 std::string GenerateApplicationNameFromExtensionId(const std::string& id); | 41 std::string GenerateApplicationNameFromExtensionId(const std::string& id); |
| 30 | 42 |
| 31 // Extracts the extension id from the app name. | 43 // Extracts the extension id from the app name. |
| 32 std::string GetExtensionIdFromApplicationName(const std::string& app_name); | 44 std::string GetExtensionIdFromApplicationName(const std::string& app_name); |
| 33 | 45 |
| 34 // Creates a shortcut for web application based on given shortcut data. | 46 // Creates a shortcut for web application based on given shortcut data. |
| 35 // |profile_path| is used as root directory for persisted data such as icon. | 47 // |profile_path| is used as root directory for persisted data such as icon. |
| 36 // Directory layout is similar to what Gears has, i.e. an web application's | 48 // Directory layout is similar to what Gears has, i.e. an web application's |
| 37 // file is stored under "#/host_name/scheme_port", where '#' is the | 49 // file is stored under "#/host_name/scheme_port", where '#' is the |
| 38 // |root_dir|. A crx based app uses a directory named _crx_<app id>. | 50 // |root_dir|. A crx based app uses a directory named _crx_<app id>. |
| 39 void CreateShortcut( | 51 void CreateShortcut( |
| 40 const FilePath& profile_path, | 52 const FilePath& profile_path, |
| 41 const ShellIntegration::ShortcutInfo& shortcut_info); | 53 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 42 | 54 |
| 43 // Returns true if given url is a valid web app url. | 55 // Returns true if given url is a valid web app url. |
| 44 bool IsValidUrl(const GURL& url); | 56 bool IsValidUrl(const GURL& url); |
| 45 | 57 |
| 46 // Returns data dir for web apps for given profile path. | |
| 47 FilePath GetDataDir(const FilePath& profile_path); | |
| 48 | |
| 49 #if defined(TOOLKIT_VIEWS) | 58 #if defined(TOOLKIT_VIEWS) |
| 50 // Extracts icons info from web app data. Take only square shaped icons and | 59 // Extracts icons info from web app data. Take only square shaped icons and |
| 51 // sort them from smallest to largest. | 60 // sort them from smallest to largest. |
| 52 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; | 61 typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList; |
| 53 void GetIconsInfo(const WebApplicationInfo& app_info, | 62 void GetIconsInfo(const WebApplicationInfo& app_info, |
| 54 IconInfoList* icons); | 63 IconInfoList* icons); |
| 55 #endif | 64 #endif |
| 56 | 65 |
| 57 #if defined(TOOLKIT_USES_GTK) | 66 #if defined(TOOLKIT_USES_GTK) |
| 58 // GTK+ windows that correspond to web apps need to have a deterministic (and | 67 // GTK+ windows that correspond to web apps need to have a deterministic (and |
| 59 // different) WMClass than normal chrome windows so the window manager groups | 68 // different) WMClass than normal chrome windows so the window manager groups |
| 60 // them as a separate application. | 69 // them as a separate application. |
| 61 std::string GetWMClassFromAppName(std::string app_name); | 70 std::string GetWMClassFromAppName(std::string app_name); |
| 62 #endif | 71 #endif |
| 63 | 72 |
| 64 namespace internals { | 73 namespace internals { |
| 65 | 74 |
| 66 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
| 67 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); | 76 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); |
| 68 #endif | 77 #endif |
| 69 | 78 |
| 70 FilePath GetWebAppDataDirectory(const FilePath& root_dir, | |
| 71 const ShellIntegration::ShortcutInfo& info); | |
| 72 | |
| 73 // Does the actual job of creating a shortcut (see CreateShortcut() above). | 79 // Does the actual job of creating a shortcut (see CreateShortcut() above). |
| 74 // This must be called on the file thread. | 80 // This must be called on the file thread. |
| 75 void CreateShortcutTask(const FilePath& web_app_path, | 81 void CreateShortcutTask(const FilePath& web_app_path, |
| 76 const FilePath& profile_path, | 82 const FilePath& profile_path, |
| 77 const ShellIntegration::ShortcutInfo& shortcut_info); | 83 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 78 | 84 |
| 79 // Sanitizes |name| and returns a version of it that is safe to use as an | 85 // Sanitizes |name| and returns a version of it that is safe to use as an |
| 80 // on-disk file name . | 86 // on-disk file name . |
| 81 FilePath GetSanitizedFileName(const string16& name); | 87 FilePath GetSanitizedFileName(const string16& name); |
| 82 | 88 |
| 83 } // namespace internals | 89 } // namespace internals |
| 84 | 90 |
| 85 } // namespace web_app | 91 } // namespace web_app |
| 86 | 92 |
| 87 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 93 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| OLD | NEW |