| 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 |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/android/shortcut_info.h" | 16 #include "chrome/browser/android/shortcut_info.h" |
| 16 #include "chrome/browser/android/webapk/webapk_info.h" | 17 #include "chrome/browser/android/webapk/webapk_info.h" |
| 17 #include "chrome/browser/android/webapk/webapk_install_service.h" | 18 #include "chrome/browser/android/webapk/webapk_install_service.h" |
| 18 #include "chrome/browser/android/webapk/webapk_installer.h" | 19 #include "chrome/browser/android/webapk/webapk_installer.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class WebContents; | 23 class WebContents; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's | 26 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's |
| 26 // ShortcutHelper in Java. | 27 // ShortcutHelper in Java. |
| 27 class ShortcutHelper { | 28 class ShortcutHelper { |
| 28 public: | 29 public: |
| 29 using WebApkInfoCallback = | 30 using WebApkInfoCallback = |
| 30 base::Callback<void(const std::vector<WebApkInfo>&)>; | 31 base::Callback<void(const std::vector<WebApkInfo>&)>; |
| 31 | 32 |
| 32 // Registers JNI hooks. | 33 // Registers JNI hooks. |
| 33 static bool RegisterShortcutHelper(JNIEnv* env); | 34 static bool RegisterShortcutHelper(JNIEnv* env); |
| 34 | 35 |
| 35 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut | 36 // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut |
| 36 // added depends on the properties in |info|. | 37 // added depends on the properties in |info|. |
| 37 static void AddToLauncherWithSkBitmap(content::WebContents* web_contents, | 38 static void AddToLauncherWithSkBitmap(content::WebContents* web_contents, |
| 38 const ShortcutInfo& info, | 39 const ShortcutInfo& info, |
| 40 const base::string16& user_title, |
| 39 const SkBitmap& icon_bitmap); | 41 const SkBitmap& icon_bitmap); |
| 40 | 42 |
| 41 // Installs WebAPK and adds shortcut to the launcher. | 43 // Installs WebAPK and adds shortcut to the launcher. |
| 42 static void InstallWebApkWithSkBitmap( | 44 static void InstallWebApkWithSkBitmap( |
| 43 content::WebContents* web_contents, | 45 content::WebContents* web_contents, |
| 44 const ShortcutInfo& info, | 46 const ShortcutInfo& info, |
| 45 const SkBitmap& primary_icon_bitmap, | 47 const SkBitmap& primary_icon_bitmap, |
| 46 const SkBitmap& badge_icon_bitmap, | 48 const SkBitmap& badge_icon_bitmap, |
| 47 const WebApkInstallService::FinishCallback& callback); | 49 const WebApkInstallService::FinishCallback& callback); |
| 48 | 50 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 108 |
| 107 // Fetches information on all the WebAPKs installed on the device and returns | 109 // Fetches information on all the WebAPKs installed on the device and returns |
| 108 // the info to the |callback|. | 110 // the info to the |callback|. |
| 109 static void RetrieveWebApks(const WebApkInfoCallback& callback); | 111 static void RetrieveWebApks(const WebApkInfoCallback& callback); |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 DISALLOW_IMPLICIT_CONSTRUCTORS(ShortcutHelper); | 114 DISALLOW_IMPLICIT_CONSTRUCTORS(ShortcutHelper); |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 117 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |