Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Side by Side Diff: chrome/browser/android/shortcut_helper.h

Issue 1845233002: Store standalone web app data in WebappDataStorage as well as the homescreen intent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-deep-linking
Patch Set: Final nit Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/macros.h" 11 #include "base/macros.h"
11 #include "chrome/browser/android/shortcut_info.h" 12 #include "chrome/browser/android/shortcut_info.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 14
14 namespace content { 15 namespace content {
15 class WebContents; 16 class WebContents;
16 } // namespace content 17 } // namespace content
17 18
18 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's 19 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's
19 // ShortcutHelper in Java. 20 // ShortcutHelper in Java.
20 class ShortcutHelper { 21 class ShortcutHelper {
21 public: 22 public:
22 // Registers JNI hooks. 23 // Registers JNI hooks.
23 static bool RegisterShortcutHelper(JNIEnv* env); 24 static bool RegisterShortcutHelper(JNIEnv* env);
24 25
25 // Adds a shortcut to the launcher using a SkBitmap. 26 // Adds a shortcut to the launcher using a SkBitmap. If the shortcut is for
26 // Must be called on the IO thread. 27 // a standalone-capable site, |splash_image_callback| will be invoked once the
27 static void AddShortcutInBackgroundWithSkBitmap(const ShortcutInfo& info, 28 // Java-side operation has completed. This is necessary as Java will
28 const std::string& webapp_id, 29 // asynchronously create and populate a WebappDataStorage object for
29 const SkBitmap& icon_bitmap); 30 // standalone-capable sites. This must exist before the splash image can be
31 // stored.
32 // Must not be called on the UI thread.
33 static void AddShortcutInBackgroundWithSkBitmap(
34 const ShortcutInfo& info,
35 const std::string& webapp_id,
36 const SkBitmap& icon_bitmap,
37 const base::Closure& splash_image_callback);
30 38
31 // Returns the ideal size for an icon representing a web app. 39 // Returns the ideal size for an icon representing a web app.
32 static int GetIdealHomescreenIconSizeInDp(); 40 static int GetIdealHomescreenIconSizeInDp();
33 41
34 // Returns the minimum size for an icon representing a web app. 42 // Returns the minimum size for an icon representing a web app.
35 static int GetMinimumHomescreenIconSizeInDp(); 43 static int GetMinimumHomescreenIconSizeInDp();
36 44
37 // Returns the ideal size for an image displayed on a web app's splash 45 // Returns the ideal size for an image displayed on a web app's splash
38 // screen. 46 // screen.
39 static int GetIdealSplashImageSizeInDp(); 47 static int GetIdealSplashImageSizeInDp();
40 48
41 // Returns the minimum size for an image displayed on a web app's splash 49 // Returns the minimum size for an image displayed on a web app's splash
42 // screen. 50 // screen.
43 static int GetMinimumSplashImageSizeInDp(); 51 static int GetMinimumSplashImageSizeInDp();
44 52
45 // Fetches the splash screen image and stores it inside the WebappDataStorage 53 // Fetches the splash screen image and stores it inside the WebappDataStorage
46 // of the webapp. 54 // of the webapp. The WebappDataStorage object *must* have been previously
55 // created by |AddShortcutInBackgroundWithSkBitmap|; this method should be
56 // passed as a closure to that method.
47 static void FetchSplashScreenImage(content::WebContents* web_contents, 57 static void FetchSplashScreenImage(content::WebContents* web_contents,
48 const GURL& image_url, 58 const GURL& image_url,
49 const int ideal_splash_image_size_in_dp, 59 const int ideal_splash_image_size_in_dp,
50 const int minimum_splash_image_size_in_dp, 60 const int minimum_splash_image_size_in_dp,
51 const std::string& webapp_id, 61 const std::string& webapp_id);
52 const std::string& webapp_scope);
53 62
54 // Stores the data of the webapp which is not placed inside the shortcut. 63 // Stores the webapp splash screen in the WebappDataStorage associated with
55 static void StoreWebappData(const std::string& webapp_id, 64 // |webapp_id|.
56 const std::string& webapp_url, 65 static void StoreWebappSplashImage(const std::string& webapp_id,
57 const SkBitmap& splash_image); 66 const SkBitmap& splash_image);
58 67
59 // Modify the given icon to matche the launcher requirements, then returns the 68 // Returns the given icon, modified to match the launcher requirements.
60 // new icon. It might generate an entirely new icon, in which case, 69 // This method may generate an entirely new icon; if this is the case,
61 // |is_generated| will be set to |true|. 70 // |is_generated| will be set to |true|.
62 static SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, 71 static SkBitmap FinalizeLauncherIcon(const SkBitmap& icon,
63 const GURL& url, 72 const GURL& url,
64 bool* is_generated); 73 bool* is_generated);
65 74
66 private: 75 private:
67 ShortcutHelper() = delete; 76 ShortcutHelper() = delete;
68 ~ShortcutHelper() = delete; 77 ~ShortcutHelper() = delete;
69 78
70 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); 79 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper);
71 }; 80 };
72 81
73 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 82 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.cc ('k') | chrome/browser/android/shortcut_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698