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 "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
| 16 class BrowserContext; |
16 class WebContents; | 17 class WebContents; |
17 } // namespace content | 18 } // namespace content |
18 | 19 |
19 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's | 20 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's |
20 // ShortcutHelper in Java. | 21 // ShortcutHelper in Java. |
21 class ShortcutHelper { | 22 class ShortcutHelper { |
22 public: | 23 public: |
23 // Registers JNI hooks. | 24 // Registers JNI hooks. |
24 static bool RegisterShortcutHelper(JNIEnv* env); | 25 static bool RegisterShortcutHelper(JNIEnv* env); |
25 | 26 |
26 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut | 27 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut |
27 // added depends on the properties in |info|. Calls one of | 28 // added depends on the properties in |info|. Calls one of |
28 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, | 29 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, |
29 // or AddShortcutInBackgroundWithSkBitmap. | 30 // or AddShortcutInBackgroundWithSkBitmap. |
30 // Must not be called on the UI thread. | 31 // Must not be called on the UI thread. |
31 static void AddToLauncherInBackgroundWithSkBitmap( | 32 static void AddToLauncherInBackgroundWithSkBitmap( |
| 33 content::BrowserContext* browser_context, |
32 const ShortcutInfo& info, | 34 const ShortcutInfo& info, |
33 const std::string& webapp_id, | 35 const std::string& webapp_id, |
34 const SkBitmap& icon_bitmap, | 36 const SkBitmap& icon_bitmap, |
35 const base::Closure& splash_image_callback); | 37 const base::Closure& splash_image_callback); |
36 | 38 |
37 // Installs WebAPK and adds shortcut to the launcher. | 39 // Installs WebAPK and adds shortcut to the launcher. |
38 // Must not be called on the UI thread. | 40 // Must not be called on the UI thread. |
39 static void InstallWebApkInBackgroundWithSkBitmap( | 41 static void InstallWebApkInBackgroundWithSkBitmap( |
| 42 content::BrowserContext* browser_context, |
40 const ShortcutInfo& info, | 43 const ShortcutInfo& info, |
41 const std::string& webapp_id, | |
42 const SkBitmap& icon_bitmap); | 44 const SkBitmap& icon_bitmap); |
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 // Must not be called on the UI thread. | 51 // Must not be called on the UI thread. |
50 static void AddWebappInBackgroundWithSkBitmap( | 52 static void AddWebappInBackgroundWithSkBitmap( |
51 const ShortcutInfo& info, | 53 const ShortcutInfo& info, |
52 const std::string& webapp_id, | 54 const std::string& webapp_id, |
53 const SkBitmap& icon_bitmap, | 55 const SkBitmap& icon_bitmap, |
54 const base::Closure& splash_image_callback); | 56 const base::Closure& splash_image_callback); |
55 | 57 |
56 // Adds a shortcut which opens in a browser tab to the launcher. | 58 // Adds a shortcut which opens in a browser tab to the launcher. |
57 // Must not be called on the UI thread. | 59 // Must not be called on the UI thread. |
58 static void AddShortcutInBackgroundWithSkBitmap( | 60 static void AddShortcutInBackgroundWithSkBitmap( |
59 const ShortcutInfo& info, | 61 const ShortcutInfo& info, |
60 const SkBitmap& icon_bitmap); | 62 const SkBitmap& icon_bitmap); |
61 | 63 |
| 64 // Called after either: |
| 65 // - A request to install the WebAPK has been sent. |
| 66 // OR |
| 67 // - WebAPK creation process fails. |
| 68 // |success| indicates whether an installation request was sent. A "true" |
| 69 // value of |success| does not guarantee that the WebAPK will be successfully |
| 70 // installed. |
| 71 static void OnBuiltWebApk(bool success); |
| 72 |
62 // Returns the ideal size for an icon representing a web app. | 73 // Returns the ideal size for an icon representing a web app. |
63 static int GetIdealHomescreenIconSizeInDp(); | 74 static int GetIdealHomescreenIconSizeInDp(); |
64 | 75 |
65 // Returns the minimum size for an icon representing a web app. | 76 // Returns the minimum size for an icon representing a web app. |
66 static int GetMinimumHomescreenIconSizeInDp(); | 77 static int GetMinimumHomescreenIconSizeInDp(); |
67 | 78 |
68 // Returns the ideal size for an image displayed on a web app's splash | 79 // Returns the ideal size for an image displayed on a web app's splash |
69 // screen. | 80 // screen. |
70 static int GetIdealSplashImageSizeInDp(); | 81 static int GetIdealSplashImageSizeInDp(); |
71 | 82 |
(...skipping 28 matching lines...) Expand all Loading... |
100 static bool IsWebApkInstalled(const GURL& url); | 111 static bool IsWebApkInstalled(const GURL& url); |
101 | 112 |
102 private: | 113 private: |
103 ShortcutHelper() = delete; | 114 ShortcutHelper() = delete; |
104 ~ShortcutHelper() = delete; | 115 ~ShortcutHelper() = delete; |
105 | 116 |
106 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 117 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
107 }; | 118 }; |
108 | 119 |
109 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 120 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |