| 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 #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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/shell_integration.h" | 13 #include "chrome/browser/shell_integration.h" |
| 14 #include "chrome/common/web_apps.h" | 14 #include "chrome/common/web_apps.h" |
| 15 | 15 |
| 16 class FilePath; | 16 class FilePath; |
| 17 class Profile; | 17 class Profile; |
| 18 class TabContents; | 18 class TabContents; |
| 19 | 19 |
| 20 namespace web_app { | 20 namespace web_app { |
| 21 | 21 |
| 22 // Compute a deterministic name based on the URL. We use this pseudo name | 22 // Compute a deterministic name based on the URL. We use this pseudo name |
| 23 // as a key to store window location per application URLs in Browser and | 23 // as a key to store window location per application URLs in Browser and |
| 24 // as app id for BrowserWindow, shortcut and jump list. | 24 // as app id for BrowserWindow, shortcut and jump list. |
| 25 std::string GenerateApplicationNameFromURL(const GURL& url); | 25 std::string GenerateApplicationNameFromURL(const GURL& url); |
| 26 | 26 |
| 27 // Compute a deterministic name based on an extension/apps's id. |
| 28 std::string GenerateApplicationNameFromExtensionId(const std::string& id); |
| 29 |
| 27 // Callback after user dismisses CreateShortcutView. "true" indicates | 30 // Callback after user dismisses CreateShortcutView. "true" indicates |
| 28 // shortcut is created successfully. Otherwise, it is false. | 31 // shortcut is created successfully. Otherwise, it is false. |
| 29 typedef Callback1<bool>::Type CreateShortcutCallback; | 32 typedef Callback1<bool>::Type CreateShortcutCallback; |
| 30 | 33 |
| 31 // Creates a shortcut for web application based on given shortcut data. | 34 // Creates a shortcut for web application based on given shortcut data. |
| 32 // |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. |
| 33 // 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 |
| 34 // file is stored under "#/host_name/scheme_port", where '#' is the | 37 // file is stored under "#/host_name/scheme_port", where '#' is the |
| 35 // |root_dir|. | 38 // |root_dir|. A crx based app uses a directory named _crx_<app id>. |
| 36 void CreateShortcut( | 39 void CreateShortcut( |
| 37 const FilePath& profile_path, | 40 const FilePath& profile_path, |
| 38 const ShellIntegration::ShortcutInfo& shortcut_info, | 41 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 39 CreateShortcutCallback* callback); | 42 CreateShortcutCallback* callback); |
| 40 | 43 |
| 41 // Returns true if given url is a valid web app url. | 44 // Returns true if given url is a valid web app url. |
| 42 bool IsValidUrl(const GURL& url); | 45 bool IsValidUrl(const GURL& url); |
| 43 | 46 |
| 44 // Returns data dir for web apps for given profile path. | 47 // Returns data dir for web apps for given profile path. |
| 45 FilePath GetDataDir(const FilePath& profile_path); | 48 FilePath GetDataDir(const FilePath& profile_path); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 // Updates web app shortcut of the TabContents. This function checks and | 62 // Updates web app shortcut of the TabContents. This function checks and |
| 60 // updates web app icon and shortcuts if needed. For icon, the check is based | 63 // updates web app icon and shortcuts if needed. For icon, the check is based |
| 61 // on MD5 hash of icon image. For shortcuts, it checks the desktop, start menu | 64 // on MD5 hash of icon image. For shortcuts, it checks the desktop, start menu |
| 62 // and quick launch (as well as pinned shortcut) for shortcut and only | 65 // and quick launch (as well as pinned shortcut) for shortcut and only |
| 63 // updates (recreates) them if they exits. | 66 // updates (recreates) them if they exits. |
| 64 void UpdateShortcutForTabContents(TabContents* tab_contents); | 67 void UpdateShortcutForTabContents(TabContents* tab_contents); |
| 65 | 68 |
| 66 }; // namespace web_app | 69 }; // namespace web_app |
| 67 | 70 |
| 68 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 71 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
| OLD | NEW |