| 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 BrowserContext; |
| 17 class WebContents; | 17 class WebContents; |
| 18 } // namespace content | 18 } // namespace content |
| 19 | 19 |
| 20 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's | 20 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's |
| 21 // ShortcutHelper in Java. | 21 // ShortcutHelper in Java. |
| 22 class ShortcutHelper { | 22 class ShortcutHelper { |
| 23 public: | 23 public: |
| 24 // Called when the package name of the WebAPK to install is available. |
| 25 using WebApkPackageNameAvailableCallback = base::Callback<void( |
| 26 const std::string& webapk_package)>; |
| 27 |
| 24 // Registers JNI hooks. | 28 // Registers JNI hooks. |
| 25 static bool RegisterShortcutHelper(JNIEnv* env); | 29 static bool RegisterShortcutHelper(JNIEnv* env); |
| 26 | 30 |
| 27 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut | 31 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut |
| 28 // added depends on the properties in |info|. Calls one of | 32 // added depends on the properties in |info|. Calls one of |
| 29 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, | 33 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, |
| 30 // or AddShortcutInBackgroundWithSkBitmap. | 34 // or AddShortcutInBackgroundWithSkBitmap. |
| 31 static void AddToLauncherWithSkBitmap( | 35 static void AddToLauncherWithSkBitmap( |
| 32 content::BrowserContext* browser_context, | 36 content::BrowserContext* browser_context, |
| 33 const ShortcutInfo& info, | 37 const ShortcutInfo& info, |
| 34 const std::string& webapp_id, | 38 const std::string& webapp_id, |
| 35 const SkBitmap& icon_bitmap, | 39 const SkBitmap& icon_bitmap, |
| 36 const base::Closure& splash_image_callback); | 40 const base::Closure& splash_image_callback); |
| 37 | 41 |
| 38 // Installs WebAPK and adds shortcut to the launcher. | 42 // Installs WebAPK and adds shortcut to the launcher. |
| 39 static void InstallWebApkWithSkBitmap( | 43 static void InstallWebApkWithSkBitmap( |
| 40 content::BrowserContext* browser_context, | 44 content::BrowserContext* browser_context, |
| 41 const ShortcutInfo& info, | 45 const ShortcutInfo& info, |
| 42 const SkBitmap& icon_bitmap); | 46 const SkBitmap& icon_bitmap, |
| 47 const WebApkPackageNameAvailableCallback& callback); |
| 43 | 48 |
| 44 // Adds a shortcut which opens in a fullscreen window to the launcher. | 49 // 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 | 50 // |splash_image_callback| will be invoked once the Java-side operation has |
| 46 // completed. This is necessary as Java will asynchronously create and | 51 // completed. This is necessary as Java will asynchronously create and |
| 47 // populate a WebappDataStorage object for standalone-capable sites. This must | 52 // populate a WebappDataStorage object for standalone-capable sites. This must |
| 48 // exist before the splash image can be stored. | 53 // exist before the splash image can be stored. |
| 49 static void AddWebappWithSkBitmap( | 54 static void AddWebappWithSkBitmap( |
| 50 const ShortcutInfo& info, | 55 const ShortcutInfo& info, |
| 51 const std::string& webapp_id, | 56 const std::string& webapp_id, |
| 52 const SkBitmap& icon_bitmap, | 57 const SkBitmap& icon_bitmap, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 static GURL GetScopeFromURL(const GURL& url); | 117 static GURL GetScopeFromURL(const GURL& url); |
| 113 | 118 |
| 114 private: | 119 private: |
| 115 ShortcutHelper() = delete; | 120 ShortcutHelper() = delete; |
| 116 ~ShortcutHelper() = delete; | 121 ~ShortcutHelper() = delete; |
| 117 | 122 |
| 118 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 123 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
| 119 }; | 124 }; |
| 120 | 125 |
| 121 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 126 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |