| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback_old.h" | |
| 13 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 14 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 15 #include "chrome/browser/shell_integration.h" | 14 #include "chrome/browser/shell_integration.h" |
| 16 #include "chrome/common/web_apps.h" | 15 #include "chrome/common/web_apps.h" |
| 17 | 16 |
| 18 namespace web_app { | 17 namespace web_app { |
| 19 | 18 |
| 20 // Compute a deterministic name based on data in the shortcut_info. | 19 // Compute a deterministic name based on data in the shortcut_info. |
| 21 std::string GenerateApplicationNameFromInfo( | 20 std::string GenerateApplicationNameFromInfo( |
| 22 const ShellIntegration::ShortcutInfo& shortcut_info); | 21 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 23 | 22 |
| 24 // Compute a deterministic name based on the URL. We use this pseudo name | 23 // Compute a deterministic name based on the URL. We use this pseudo name |
| 25 // as a key to store window location per application URLs in Browser and | 24 // as a key to store window location per application URLs in Browser and |
| 26 // as app id for BrowserWindow, shortcut and jump list. | 25 // as app id for BrowserWindow, shortcut and jump list. |
| 27 std::string GenerateApplicationNameFromURL(const GURL& url); | 26 std::string GenerateApplicationNameFromURL(const GURL& url); |
| 28 | 27 |
| 29 // Compute a deterministic name based on an extension/apps's id. | 28 // Compute a deterministic name based on an extension/apps's id. |
| 30 std::string GenerateApplicationNameFromExtensionId(const std::string& id); | 29 std::string GenerateApplicationNameFromExtensionId(const std::string& id); |
| 31 | 30 |
| 32 // Extracts the extension id from the app name. | 31 // Extracts the extension id from the app name. |
| 33 std::string GetExtensionIdFromApplicationName(const std::string& app_name); | 32 std::string GetExtensionIdFromApplicationName(const std::string& app_name); |
| 34 | 33 |
| 35 // Callback after user dismisses CreateShortcutView. "true" indicates | |
| 36 // shortcut is created successfully. Otherwise, it is false. | |
| 37 typedef Callback1<bool>::Type CreateShortcutCallback; | |
| 38 | |
| 39 // Creates a shortcut for web application based on given shortcut data. | 34 // Creates a shortcut for web application based on given shortcut data. |
| 40 // |profile_path| is used as root directory for persisted data such as icon. | 35 // |profile_path| is used as root directory for persisted data such as icon. |
| 41 // Directory layout is similar to what Gears has, i.e. an web application's | 36 // Directory layout is similar to what Gears has, i.e. an web application's |
| 42 // file is stored under "#/host_name/scheme_port", where '#' is the | 37 // file is stored under "#/host_name/scheme_port", where '#' is the |
| 43 // |root_dir|. A crx based app uses a directory named _crx_<app id>. | 38 // |root_dir|. A crx based app uses a directory named _crx_<app id>. |
| 44 void CreateShortcut( | 39 void CreateShortcut( |
| 45 const FilePath& profile_path, | 40 const FilePath& profile_path, |
| 46 const ShellIntegration::ShortcutInfo& shortcut_info, | 41 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 47 CreateShortcutCallback* callback); | |
| 48 | 42 |
| 49 // Returns true if given url is a valid web app url. | 43 // Returns true if given url is a valid web app url. |
| 50 bool IsValidUrl(const GURL& url); | 44 bool IsValidUrl(const GURL& url); |
| 51 | 45 |
| 52 // Returns data dir for web apps for given profile path. | 46 // Returns data dir for web apps for given profile path. |
| 53 FilePath GetDataDir(const FilePath& profile_path); | 47 FilePath GetDataDir(const FilePath& profile_path); |
| 54 | 48 |
| 55 #if defined(TOOLKIT_VIEWS) | 49 #if defined(TOOLKIT_VIEWS) |
| 56 // Extracts icons info from web app data. Take only square shaped icons and | 50 // Extracts icons info from web app data. Take only square shaped icons and |
| 57 // sort them from smallest to largest. | 51 // sort them from smallest to largest. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); | 69 bool CheckAndSaveIcon(const FilePath& icon_file, const SkBitmap& image); |
| 76 #endif | 70 #endif |
| 77 | 71 |
| 78 FilePath GetWebAppDataDirectory(const FilePath& root_dir, | 72 FilePath GetWebAppDataDirectory(const FilePath& root_dir, |
| 79 const ShellIntegration::ShortcutInfo& info); | 73 const ShellIntegration::ShortcutInfo& info); |
| 80 } // namespace internals | 74 } // namespace internals |
| 81 | 75 |
| 82 } // namespace web_app | 76 } // namespace web_app |
| 83 | 77 |
| 84 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 78 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| OLD | NEW |