Chromium Code Reviews| 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 WebContents; | 16 class WebContents; |
| 17 } // namespace content | 17 } // namespace content |
| 18 | 18 |
| 19 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's | 19 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's |
| 20 // ShortcutHelper in Java. | 20 // ShortcutHelper in Java. |
| 21 class ShortcutHelper { | 21 class ShortcutHelper { |
| 22 public: | 22 public: |
| 23 // Registers JNI hooks. | 23 // Registers JNI hooks. |
| 24 static bool RegisterShortcutHelper(JNIEnv* env); | 24 static bool RegisterShortcutHelper(JNIEnv* env); |
| 25 | 25 |
| 26 // Adds a shortcut to the launcher using a SkBitmap. If the shortcut is for | 26 // Adds a shortcut to the launcher using a SkBitmap. |
|
dominickn
2016/07/15 00:19:00
Nit: "The type of shortcut added depends on the pr
| |
| 27 // a standalone-capable site, |splash_image_callback| will be invoked once the | |
| 28 // Java-side operation has completed. This is necessary as Java will | |
| 29 // asynchronously create and populate a WebappDataStorage object for | |
| 30 // standalone-capable sites. This must exist before the splash image can be | |
| 31 // stored. | |
| 32 // Must not be called on the UI thread. | 27 // Must not be called on the UI thread. |
| 33 static void AddShortcutInBackgroundWithSkBitmap( | 28 static void AddShortcutInBackgroundWithSkBitmap( |
| 34 const ShortcutInfo& info, | 29 const ShortcutInfo& info, |
| 35 const std::string& webapp_id, | 30 const std::string& webapp_id, |
| 36 const SkBitmap& icon_bitmap, | 31 const SkBitmap& icon_bitmap, |
| 37 const base::Closure& splash_image_callback); | 32 const base::Closure& splash_image_callback); |
| 38 | 33 |
| 34 // Installs WebAPK and adds shortcut to the launcher. | |
| 35 // Must not be called on the UI thread. | |
| 36 static void AddWebApkInBackgroundWithSkBitmap( | |
|
dominickn
2016/07/15 00:19:00
Perhaps InstallWebApkInBackgroundWithSkBitmap for
| |
| 37 const ShortcutInfo& info, | |
| 38 const std::string& webapp_id, | |
| 39 const SkBitmap& icon_bitmap); | |
| 40 | |
| 41 // Adds a shortcut which opens in a fullscreen window to the launcher. | |
| 42 // |splash_image_callback| will be invoked once the Java-side operation has | |
| 43 // completed. This is necessary as Java will asynchronously create and | |
| 44 // populate a WebappDataStorage object for standalone-capable sites. This must | |
| 45 // exist before the splash image can be stored. | |
| 46 // Must not be called on the UI thread. | |
| 47 static void AddWebappInBackgroundWithSkBitmap( | |
| 48 const ShortcutInfo& info, | |
| 49 const std::string& webapp_id, | |
| 50 const SkBitmap& icon_bitmap, | |
| 51 const base::Closure& splash_image_callback); | |
| 52 | |
| 53 // Adds a shortcut which opens in a browser tab to the launcher. | |
| 54 // Must not be called on the UI thread. | |
| 55 static void AddBookmarkShortcutInBackgroundWithSkBitmap( | |
|
dominickn
2016/07/15 00:19:00
"Bookmark shortcut" is a bit misleading here becau
| |
| 56 const ShortcutInfo& info, | |
| 57 const SkBitmap& icon_bitmap); | |
| 58 | |
| 39 // Returns the ideal size for an icon representing a web app. | 59 // Returns the ideal size for an icon representing a web app. |
| 40 static int GetIdealHomescreenIconSizeInDp(); | 60 static int GetIdealHomescreenIconSizeInDp(); |
| 41 | 61 |
| 42 // Returns the minimum size for an icon representing a web app. | 62 // Returns the minimum size for an icon representing a web app. |
| 43 static int GetMinimumHomescreenIconSizeInDp(); | 63 static int GetMinimumHomescreenIconSizeInDp(); |
| 44 | 64 |
| 45 // Returns the ideal size for an image displayed on a web app's splash | 65 // Returns the ideal size for an image displayed on a web app's splash |
| 46 // screen. | 66 // screen. |
| 47 static int GetIdealSplashImageSizeInDp(); | 67 static int GetIdealSplashImageSizeInDp(); |
| 48 | 68 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 77 static bool IsWebApkInstalled(const GURL& url); | 97 static bool IsWebApkInstalled(const GURL& url); |
| 78 | 98 |
| 79 private: | 99 private: |
| 80 ShortcutHelper() = delete; | 100 ShortcutHelper() = delete; |
| 81 ~ShortcutHelper() = delete; | 101 ~ShortcutHelper() = delete; |
| 82 | 102 |
| 83 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 103 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
| 84 }; | 104 }; |
| 85 | 105 |
| 86 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 106 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |