OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ANDROID_SHORTCUT_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
6 #define CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 6 #define CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "chrome/browser/android/shortcut_info.h" | 12 #include "chrome/browser/android/shortcut_info.h" |
| 13 #include "chrome/browser/android/webapk/webapk_installer.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 class BrowserContext; | 17 class BrowserContext; |
17 class WebContents; | 18 class WebContents; |
18 } // namespace content | 19 } // namespace content |
19 | 20 |
20 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's | 21 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's |
21 // ShortcutHelper in Java. | 22 // ShortcutHelper in Java. |
22 class ShortcutHelper { | 23 class ShortcutHelper { |
23 public: | 24 public: |
24 // Registers JNI hooks. | 25 // Registers JNI hooks. |
25 static bool RegisterShortcutHelper(JNIEnv* env); | 26 static bool RegisterShortcutHelper(JNIEnv* env); |
26 | 27 |
27 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut | 28 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut |
28 // added depends on the properties in |info|. Calls one of | 29 // added depends on the properties in |info|. Calls one of |
29 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, | 30 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, |
30 // or AddShortcutInBackgroundWithSkBitmap. | 31 // or AddShortcutInBackgroundWithSkBitmap. |
31 static void AddToLauncherWithSkBitmap( | 32 static void AddToLauncherWithSkBitmap( |
32 content::BrowserContext* browser_context, | 33 content::BrowserContext* browser_context, |
33 const ShortcutInfo& info, | 34 const ShortcutInfo& info, |
34 const std::string& webapp_id, | 35 const std::string& webapp_id, |
35 const SkBitmap& icon_bitmap, | 36 const SkBitmap& icon_bitmap, |
36 const base::Closure& splash_image_callback); | 37 const base::Closure& splash_image_callback); |
37 | 38 |
38 // Installs WebAPK and adds shortcut to the launcher. | 39 // Installs WebAPK and adds shortcut to the launcher. |
39 static void InstallWebApkWithSkBitmap( | 40 static void InstallWebApkWithSkBitmap( |
40 content::BrowserContext* browser_context, | 41 content::BrowserContext* browser_context, |
41 const ShortcutInfo& info, | 42 const ShortcutInfo& info, |
42 const SkBitmap& icon_bitmap); | 43 const SkBitmap& icon_bitmap, |
| 44 const WebApkInstaller::FinishCallback& callback); |
43 | 45 |
44 // Adds a shortcut which opens in a fullscreen window to the launcher. | 46 // Adds a shortcut which opens in a fullscreen window to the launcher. |
45 // |splash_image_callback| will be invoked once the Java-side operation has | 47 // |splash_image_callback| will be invoked once the Java-side operation has |
46 // completed. This is necessary as Java will asynchronously create and | 48 // completed. This is necessary as Java will asynchronously create and |
47 // populate a WebappDataStorage object for standalone-capable sites. This must | 49 // populate a WebappDataStorage object for standalone-capable sites. This must |
48 // exist before the splash image can be stored. | 50 // exist before the splash image can be stored. |
49 static void AddWebappWithSkBitmap( | 51 static void AddWebappWithSkBitmap( |
50 const ShortcutInfo& info, | 52 const ShortcutInfo& info, |
51 const std::string& webapp_id, | 53 const std::string& webapp_id, |
52 const SkBitmap& icon_bitmap, | 54 const SkBitmap& icon_bitmap, |
53 const base::Closure& splash_image_callback); | 55 const base::Closure& splash_image_callback); |
54 | 56 |
55 // Adds a shortcut which opens in a browser tab to the launcher. | 57 // Adds a shortcut which opens in a browser tab to the launcher. |
56 static void AddShortcutWithSkBitmap( | 58 static void AddShortcutWithSkBitmap( |
57 const ShortcutInfo& info, | 59 const ShortcutInfo& info, |
58 const SkBitmap& icon_bitmap); | 60 const SkBitmap& icon_bitmap); |
59 | 61 |
60 // Called after either: | |
61 // - A request to install the WebAPK has been sent. | |
62 // OR | |
63 // - WebAPK creation process fails. | |
64 // |success| indicates whether an installation request was sent. A "true" | |
65 // value of |success| does not guarantee that the WebAPK will be successfully | |
66 // installed. | |
67 static void OnBuiltWebApk(bool success); | |
68 | |
69 // Returns the ideal size for an icon representing a web app. | 62 // Returns the ideal size for an icon representing a web app. |
70 static int GetIdealHomescreenIconSizeInDp(); | 63 static int GetIdealHomescreenIconSizeInDp(); |
71 | 64 |
72 // Returns the minimum size for an icon representing a web app. | 65 // Returns the minimum size for an icon representing a web app. |
73 static int GetMinimumHomescreenIconSizeInDp(); | 66 static int GetMinimumHomescreenIconSizeInDp(); |
74 | 67 |
75 // Returns the ideal size for an image displayed on a web app's splash | 68 // Returns the ideal size for an image displayed on a web app's splash |
76 // screen. | 69 // screen. |
77 static int GetIdealSplashImageSizeInDp(); | 70 static int GetIdealSplashImageSizeInDp(); |
78 | 71 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 static GURL GetScopeFromURL(const GURL& url); | 105 static GURL GetScopeFromURL(const GURL& url); |
113 | 106 |
114 private: | 107 private: |
115 ShortcutHelper() = delete; | 108 ShortcutHelper() = delete; |
116 ~ShortcutHelper() = delete; | 109 ~ShortcutHelper() = delete; |
117 | 110 |
118 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 111 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
119 }; | 112 }; |
120 | 113 |
121 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 114 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |