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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // ShortcutHelper in Java. | 21 // ShortcutHelper in Java. |
22 class ShortcutHelper { | 22 class ShortcutHelper { |
23 public: | 23 public: |
24 // Registers JNI hooks. | 24 // Registers JNI hooks. |
25 static bool RegisterShortcutHelper(JNIEnv* env); | 25 static bool RegisterShortcutHelper(JNIEnv* env); |
26 | 26 |
27 // 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 |
28 // added depends on the properties in |info|. Calls one of | 28 // added depends on the properties in |info|. Calls one of |
29 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, | 29 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, |
30 // or AddShortcutInBackgroundWithSkBitmap. | 30 // or AddShortcutInBackgroundWithSkBitmap. |
31 // Must not be called on the UI thread. | 31 static void AddToLauncherWithSkBitmap( |
32 static void AddToLauncherInBackgroundWithSkBitmap( | |
33 content::BrowserContext* browser_context, | 32 content::BrowserContext* browser_context, |
34 const ShortcutInfo& info, | 33 const ShortcutInfo& info, |
35 const std::string& webapp_id, | 34 const std::string& webapp_id, |
36 const SkBitmap& icon_bitmap, | 35 const SkBitmap& icon_bitmap, |
37 const base::Closure& splash_image_callback); | 36 const base::Closure& splash_image_callback); |
38 | 37 |
39 // Installs WebAPK and adds shortcut to the launcher. | 38 // Installs WebAPK and adds shortcut to the launcher. |
40 // Must not be called on the UI thread. | 39 static void InstallWebApkWithSkBitmap( |
41 static void InstallWebApkInBackgroundWithSkBitmap( | |
42 content::BrowserContext* browser_context, | 40 content::BrowserContext* browser_context, |
43 const ShortcutInfo& info, | 41 const ShortcutInfo& info, |
44 const SkBitmap& icon_bitmap); | 42 const SkBitmap& icon_bitmap); |
45 | 43 |
46 // Adds a shortcut which opens in a fullscreen window to the launcher. | 44 // Adds a shortcut which opens in a fullscreen window to the launcher. |
47 // |splash_image_callback| will be invoked once the Java-side operation has | 45 // |splash_image_callback| will be invoked once the Java-side operation has |
48 // completed. This is necessary as Java will asynchronously create and | 46 // completed. This is necessary as Java will asynchronously create and |
49 // populate a WebappDataStorage object for standalone-capable sites. This must | 47 // populate a WebappDataStorage object for standalone-capable sites. This must |
50 // exist before the splash image can be stored. | 48 // exist before the splash image can be stored. |
51 // Must not be called on the UI thread. | 49 static void AddWebappWithSkBitmap( |
52 static void AddWebappInBackgroundWithSkBitmap( | |
53 const ShortcutInfo& info, | 50 const ShortcutInfo& info, |
54 const std::string& webapp_id, | 51 const std::string& webapp_id, |
55 const SkBitmap& icon_bitmap, | 52 const SkBitmap& icon_bitmap, |
56 const base::Closure& splash_image_callback); | 53 const base::Closure& splash_image_callback); |
57 | 54 |
58 // Adds a shortcut which opens in a browser tab to the launcher. | 55 // Adds a shortcut which opens in a browser tab to the launcher. |
59 // Must not be called on the UI thread. | 56 static void AddShortcutWithSkBitmap( |
60 static void AddShortcutInBackgroundWithSkBitmap( | |
61 const ShortcutInfo& info, | 57 const ShortcutInfo& info, |
62 const SkBitmap& icon_bitmap); | 58 const SkBitmap& icon_bitmap); |
63 | 59 |
64 // Called after either: | 60 // Called after either: |
65 // - A request to install the WebAPK has been sent. | 61 // - A request to install the WebAPK has been sent. |
66 // OR | 62 // OR |
67 // - WebAPK creation process fails. | 63 // - WebAPK creation process fails. |
68 // |success| indicates whether an installation request was sent. A "true" | 64 // |success| indicates whether an installation request was sent. A "true" |
69 // value of |success| does not guarantee that the WebAPK will be successfully | 65 // value of |success| does not guarantee that the WebAPK will be successfully |
70 // installed. | 66 // installed. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 static GURL GetScopeFromURL(const GURL& url); | 112 static GURL GetScopeFromURL(const GURL& url); |
117 | 113 |
118 private: | 114 private: |
119 ShortcutHelper() = delete; | 115 ShortcutHelper() = delete; |
120 ~ShortcutHelper() = delete; | 116 ~ShortcutHelper() = delete; |
121 | 117 |
122 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 118 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
123 }; | 119 }; |
124 | 120 |
125 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 121 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |