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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/shell_integration.h" | 15 #include "chrome/browser/shell_integration.h" |
16 #include "chrome/common/web_application_info.h" | 16 #include "chrome/common/web_application_info.h" |
17 | 17 |
18 class Profile; | 18 class Profile; |
19 | 19 |
| 20 namespace content { |
| 21 class WebContents; |
| 22 } |
| 23 |
20 namespace extensions { | 24 namespace extensions { |
21 class Extension; | 25 class Extension; |
22 } | 26 } |
23 | 27 |
24 namespace gfx { | 28 namespace gfx { |
25 class ImageFamily; | 29 class ImageFamily; |
26 } | 30 } |
27 | 31 |
28 namespace web_app { | 32 namespace web_app { |
29 | 33 |
30 // This encodes the cause of shortcut creation as the correct behavior in each | 34 // This encodes the cause of shortcut creation as the correct behavior in each |
31 // case is implementation specific. | 35 // case is implementation specific. |
32 enum ShortcutCreationReason { | 36 enum ShortcutCreationReason { |
33 SHORTCUT_CREATION_BY_USER, | 37 SHORTCUT_CREATION_BY_USER, |
34 SHORTCUT_CREATION_AUTOMATED, | 38 SHORTCUT_CREATION_AUTOMATED, |
35 }; | 39 }; |
36 | 40 |
37 typedef base::Callback<void(const ShellIntegration::ShortcutInfo&)> | 41 typedef base::Callback<void(const ShellIntegration::ShortcutInfo&)> |
38 ShortcutInfoCallback; | 42 ShortcutInfoCallback; |
39 | 43 |
| 44 // Extracts shortcut info of the given WebContents. |
| 45 void GetShortcutInfoForTab(content::WebContents* web_contents, |
| 46 ShellIntegration::ShortcutInfo* info); |
| 47 |
| 48 // Updates web app shortcut of the WebContents. This function checks and |
| 49 // updates web app icon and shortcuts if needed. For icon, the check is based |
| 50 // on MD5 hash of icon image. For shortcuts, it checks the desktop, start menu |
| 51 // and quick launch (as well as pinned shortcut) for shortcut and only |
| 52 // updates (recreates) them if they exits. |
| 53 void UpdateShortcutForTabContents(content::WebContents* web_contents); |
| 54 |
40 ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile( | 55 ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile( |
41 const extensions::Extension* app, | 56 const extensions::Extension* app, |
42 Profile* profile); | 57 Profile* profile); |
43 | 58 |
44 // Fetches the icon for |extension| and calls |callback| with shortcut info | 59 // Fetches the icon for |extension| and calls |callback| with shortcut info |
45 // filled out as by UpdateShortcutInfoForApp. | 60 // filled out as by UpdateShortcutInfoForApp. |
46 void UpdateShortcutInfoAndIconForApp( | 61 void UpdateShortcutInfoAndIconForApp( |
47 const extensions::Extension* extension, | 62 const extensions::Extension* extension, |
48 Profile* profile, | 63 Profile* profile, |
49 const ShortcutInfoCallback& callback); | 64 const ShortcutInfoCallback& callback); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 178 |
164 // Sanitizes |name| and returns a version of it that is safe to use as an | 179 // Sanitizes |name| and returns a version of it that is safe to use as an |
165 // on-disk file name . | 180 // on-disk file name . |
166 base::FilePath GetSanitizedFileName(const base::string16& name); | 181 base::FilePath GetSanitizedFileName(const base::string16& name); |
167 | 182 |
168 } // namespace internals | 183 } // namespace internals |
169 | 184 |
170 } // namespace web_app | 185 } // namespace web_app |
171 | 186 |
172 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ | 187 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_ |
OLD | NEW |