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_EXTENSIONS_CONVERT_WEB_APP_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CONVERT_WEB_APP_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CONVERT_WEB_APP_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CONVERT_WEB_APP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 | 12 |
13 class Extension; | |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 class Time; | 15 class Time; |
17 } | 16 } |
18 | 17 |
| 18 namespace extensions { |
| 19 class Extension; |
| 20 } |
| 21 |
19 struct WebApplicationInfo; | 22 struct WebApplicationInfo; |
20 | 23 |
21 // Generates a version number for an extension from a time. The goal is to make | 24 // Generates a version number for an extension from a time. The goal is to make |
22 // use of the version number to communicate the date in a human readable form, | 25 // use of the version number to communicate the date in a human readable form, |
23 // while maintaining high enough resolution to change each time an app is | 26 // while maintaining high enough resolution to change each time an app is |
24 // reinstalled. The version that is returned has the format: | 27 // reinstalled. The version that is returned has the format: |
25 // | 28 // |
26 // <year>.<month>.<day>.<fraction> | 29 // <year>.<month>.<day>.<fraction> |
27 // | 30 // |
28 // fraction is represented as a number between 0 and 2^16-1. Each unit is | 31 // fraction is represented as a number between 0 and 2^16-1. Each unit is |
29 // ~1.32 seconds. | 32 // ~1.32 seconds. |
30 std::string ConvertTimeToExtensionVersion(const base::Time& time); | 33 std::string ConvertTimeToExtensionVersion(const base::Time& time); |
31 | 34 |
32 // Wraps the specified web app in an extension. The extension is created | 35 // Wraps the specified web app in an extension. The extension is created |
33 // unpacked in the system temp dir. Returns a valid extension that the caller | 36 // unpacked in the system temp dir. Returns a valid extension that the caller |
34 // should take ownership on success, or NULL and |error| on failure. | 37 // should take ownership on success, or NULL and |error| on failure. |
35 // | 38 // |
36 // NOTE: This function does file IO and should not be called on the UI thread. | 39 // NOTE: This function does file IO and should not be called on the UI thread. |
37 // NOTE: The caller takes ownership of the directory at extension->path() on the | 40 // NOTE: The caller takes ownership of the directory at extension->path() on the |
38 // returned object. | 41 // returned object. |
39 scoped_refptr<Extension> ConvertWebAppToExtension( | 42 scoped_refptr<extensions::Extension> ConvertWebAppToExtension( |
40 const WebApplicationInfo& web_app_info, | 43 const WebApplicationInfo& web_app_info, |
41 const base::Time& create_time); | 44 const base::Time& create_time); |
42 | 45 |
43 #endif // CHROME_BROWSER_EXTENSIONS_CONVERT_WEB_APP_H_ | 46 #endif // CHROME_BROWSER_EXTENSIONS_CONVERT_WEB_APP_H_ |
OLD | NEW |