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

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

Issue 2138973002: Initial CL for talking to the WebAPK server to generate WebAPK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'webapk_builder_impl0' into webapk_builder_impl2 Created 4 years, 5 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/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 WebContents; 17 class WebContents;
17 } // namespace content 18 } // namespace content
18 19
19 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's 20 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's
20 // ShortcutHelper in Java. 21 // ShortcutHelper in Java.
21 class ShortcutHelper { 22 class ShortcutHelper {
22 public: 23 public:
23 // Registers JNI hooks. 24 // Registers JNI hooks.
24 static bool RegisterShortcutHelper(JNIEnv* env); 25 static bool RegisterShortcutHelper(JNIEnv* env);
25 26
26 // Adds a shortcut to the launcher using a SkBitmap. 27 // Adds a shortcut to the launcher using a SkBitmap.
27 // Must not be called on the UI thread. 28 // Must not be called on the UI thread.
28 static void AddShortcutInBackgroundWithSkBitmap( 29 static void AddShortcutInBackgroundWithSkBitmap(
30 content::BrowserContext* browser_context,
29 const ShortcutInfo& info, 31 const ShortcutInfo& info,
30 const std::string& webapp_id, 32 const std::string& webapp_id,
31 const SkBitmap& icon_bitmap, 33 const SkBitmap& icon_bitmap,
32 const base::Closure& splash_image_callback); 34 const base::Closure& splash_image_callback);
33 35
34 // Installs WebAPK and adds shortcut to the launcher. 36 // Installs WebAPK and adds shortcut to the launcher.
35 // Must not be called on the UI thread. 37 // Must not be called on the UI thread.
36 static void AddWebApkInBackgroundWithSkBitmap( 38 static void AddWebApkInBackgroundWithSkBitmap(
39 content::BrowserContext* browser_context,
37 const ShortcutInfo& info, 40 const ShortcutInfo& info,
38 const std::string& webapp_id,
39 const SkBitmap& icon_bitmap); 41 const SkBitmap& icon_bitmap);
40 42
41 // Adds a shortcut which opens in a fullscreen window to the launcher. 43 // 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 44 // |splash_image_callback| will be invoked once the Java-side operation has
43 // completed. This is necessary as Java will asynchronously create and 45 // completed. This is necessary as Java will asynchronously create and
44 // populate a WebappDataStorage object for standalone-capable sites. This must 46 // populate a WebappDataStorage object for standalone-capable sites. This must
45 // exist before the splash image can be stored. 47 // exist before the splash image can be stored.
46 // Must not be called on the UI thread. 48 // Must not be called on the UI thread.
47 static void AddWebappInBackgroundWithSkBitmap( 49 static void AddWebappInBackgroundWithSkBitmap(
48 const ShortcutInfo& info, 50 const ShortcutInfo& info,
49 const std::string& webapp_id, 51 const std::string& webapp_id,
50 const SkBitmap& icon_bitmap, 52 const SkBitmap& icon_bitmap,
51 const base::Closure& splash_image_callback); 53 const base::Closure& splash_image_callback);
52 54
53 // Adds a shortcut which opens in a browser tab to the launcher. 55 // Adds a shortcut which opens in a browser tab to the launcher.
54 // Must not be called on the UI thread. 56 // Must not be called on the UI thread.
55 static void AddBookmarkShortcutInBackgroundWithSkBitmap( 57 static void AddBookmarkShortcutInBackgroundWithSkBitmap(
56 const ShortcutInfo& info, 58 const ShortcutInfo& info,
57 const SkBitmap& icon_bitmap); 59 const SkBitmap& icon_bitmap);
58 60
61 // Called after either:
62 // - A request to download and install the WebAPK has been sent to
Yaron 2016/07/19 17:31:13 .. has been sent.
63 // the Google Play server.
64 // OR
65 // - WebAPK creation process fails.
66 // |success| indicates whether the request was sent to the Google Play server.
Yaron 2016/07/19 17:31:13 |success| indicates whether the request was issued
67 // A "true" value of |success| does not guarantee that the WebAPK will be
68 // successfully downloaded from the WebAPK server.
69 static void OnBuiltWebApk(bool success);
70
59 // Returns the ideal size for an icon representing a web app. 71 // Returns the ideal size for an icon representing a web app.
60 static int GetIdealHomescreenIconSizeInDp(); 72 static int GetIdealHomescreenIconSizeInDp();
61 73
62 // Returns the minimum size for an icon representing a web app. 74 // Returns the minimum size for an icon representing a web app.
63 static int GetMinimumHomescreenIconSizeInDp(); 75 static int GetMinimumHomescreenIconSizeInDp();
64 76
65 // Returns the ideal size for an image displayed on a web app's splash 77 // Returns the ideal size for an image displayed on a web app's splash
66 // screen. 78 // screen.
67 static int GetIdealSplashImageSizeInDp(); 79 static int GetIdealSplashImageSizeInDp();
68 80
(...skipping 28 matching lines...) Expand all
97 static bool IsWebApkInstalled(const GURL& url); 109 static bool IsWebApkInstalled(const GURL& url);
98 110
99 private: 111 private:
100 ShortcutHelper() = delete; 112 ShortcutHelper() = delete;
101 ~ShortcutHelper() = delete; 113 ~ShortcutHelper() = delete;
102 114
103 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); 115 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper);
104 }; 116 };
105 117
106 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 118 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698