| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // ShortcutHelper in Java. | 26 // ShortcutHelper in Java. |
| 27 class ShortcutHelper { | 27 class ShortcutHelper { |
| 28 public: | 28 public: |
| 29 using WebApkInfoCallback = | 29 using WebApkInfoCallback = |
| 30 base::Callback<void(const std::vector<WebApkInfo>&)>; | 30 base::Callback<void(const std::vector<WebApkInfo>&)>; |
| 31 | 31 |
| 32 // Registers JNI hooks. | 32 // Registers JNI hooks. |
| 33 static bool RegisterShortcutHelper(JNIEnv* env); | 33 static bool RegisterShortcutHelper(JNIEnv* env); |
| 34 | 34 |
| 35 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut | 35 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut |
| 36 // added depends on the properties in |info|. Calls one of | 36 // added depends on the properties in |info|. |
| 37 // InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap, | |
| 38 // or AddShortcutInBackgroundWithSkBitmap. | |
| 39 static void AddToLauncherWithSkBitmap(content::WebContents* web_contents, | 37 static void AddToLauncherWithSkBitmap(content::WebContents* web_contents, |
| 40 const ShortcutInfo& info, | 38 const ShortcutInfo& info, |
| 41 const SkBitmap& icon_bitmap); | 39 const SkBitmap& icon_bitmap); |
| 42 | 40 |
| 43 // Installs WebAPK and adds shortcut to the launcher. | 41 // Installs WebAPK and adds shortcut to the launcher. |
| 44 static void InstallWebApkWithSkBitmap( | 42 static void InstallWebApkWithSkBitmap( |
| 45 content::WebContents* web_conetnts, | 43 content::WebContents* web_contents, |
| 46 const ShortcutInfo& info, | 44 const ShortcutInfo& info, |
| 47 const SkBitmap& icon_bitmap, | 45 const SkBitmap& primary_icon_bitmap, |
| 46 const SkBitmap& badge_icon_bitmap, |
| 48 const WebApkInstallService::FinishCallback& callback); | 47 const WebApkInstallService::FinishCallback& callback); |
| 49 | 48 |
| 50 // Shows toast notifying user that a WebAPK install is already in progress | 49 // Shows toast notifying user that a WebAPK install is already in progress |
| 51 // when user tries to queue a new install for the same WebAPK. | 50 // when user tries to queue a new install for the same WebAPK. |
| 52 static void ShowWebApkInstallInProgressToast(); | 51 static void ShowWebApkInstallInProgressToast(); |
| 53 | 52 |
| 54 // Returns the ideal size for an icon representing a web app or a WebAPK. | 53 // Returns the ideal size for an icon representing a web app or a WebAPK. |
| 55 static int GetIdealHomescreenIconSizeInPx(); | 54 static int GetIdealHomescreenIconSizeInPx(); |
| 56 | 55 |
| 57 // Returns the minimum size for an icon representing a web app or a WebAPK. | 56 // Returns the minimum size for an icon representing a web app or a WebAPK. |
| 58 static int GetMinimumHomescreenIconSizeInPx(); | 57 static int GetMinimumHomescreenIconSizeInPx(); |
| 59 | 58 |
| 60 // Returns the ideal size for an image displayed on a web app's splash | 59 // Returns the ideal size for an image displayed on a web app's splash |
| 61 // screen. | 60 // screen. |
| 62 static int GetIdealSplashImageSizeInPx(); | 61 static int GetIdealSplashImageSizeInPx(); |
| 63 | 62 |
| 64 // Returns the minimum size for an image displayed on a web app's splash | 63 // Returns the minimum size for an image displayed on a web app's splash |
| 65 // screen. | 64 // screen. |
| 66 static int GetMinimumSplashImageSizeInPx(); | 65 static int GetMinimumSplashImageSizeInPx(); |
| 67 | 66 |
| 68 // Returns the ideal size for a badge icon of a WebAPK. | 67 // Returns the ideal size for a badge icon of a WebAPK. |
| 69 static int GetIdealBadgeIconSizeInPx(); | 68 static int GetIdealBadgeIconSizeInPx(); |
| 70 | 69 |
| 71 // Fetches the splash screen image and stores it inside the WebappDataStorage | 70 // Fetches the splash screen image and stores it inside the WebappDataStorage |
| 72 // of the webapp. The WebappDataStorage object *must* have been previously | 71 // of the webapp. The WebappDataStorage object *must* have been previously |
| 73 // created by |AddShortcutInBackgroundWithSkBitmap|; this method should be | 72 // created by AddToLauncherWithSkBitmap(); this method should be passed as a |
| 74 // passed as a closure to that method. | 73 // closure to that method. |
| 75 static void FetchSplashScreenImage(content::WebContents* web_contents, | 74 static void FetchSplashScreenImage(content::WebContents* web_contents, |
| 76 const GURL& image_url, | 75 const GURL& image_url, |
| 77 const int ideal_splash_image_size_in_px, | 76 const int ideal_splash_image_size_in_px, |
| 78 const int minimum_splash_image_size_in_px, | 77 const int minimum_splash_image_size_in_px, |
| 79 const std::string& webapp_id); | 78 const std::string& webapp_id); |
| 80 | 79 |
| 81 // Stores the webapp splash screen in the WebappDataStorage associated with | 80 // Stores the webapp splash screen in the WebappDataStorage associated with |
| 82 // |webapp_id|. | 81 // |webapp_id|. |
| 83 static void StoreWebappSplashImage(const std::string& webapp_id, | 82 static void StoreWebappSplashImage(const std::string& webapp_id, |
| 84 const SkBitmap& splash_image); | 83 const SkBitmap& splash_image); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 107 | 106 |
| 108 // Fetches information on all the WebAPKs installed on the device and returns | 107 // Fetches information on all the WebAPKs installed on the device and returns |
| 109 // the info to the |callback|. | 108 // the info to the |callback|. |
| 110 static void RetrieveWebApks(const WebApkInfoCallback& callback); | 109 static void RetrieveWebApks(const WebApkInfoCallback& callback); |
| 111 | 110 |
| 112 private: | 111 private: |
| 113 DISALLOW_IMPLICIT_CONSTRUCTORS(ShortcutHelper); | 112 DISALLOW_IMPLICIT_CONSTRUCTORS(ShortcutHelper); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 115 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |