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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Use FaviconService to get the best available favicon and create the | 71 // Use FaviconService to get the best available favicon and create the |
72 // shortcut using it. This is used when no Manifest icons are available or | 72 // shortcut using it. This is used when no Manifest icons are available or |
73 // appropriate. | 73 // appropriate. |
74 void AddShortcutUsingFavicon(); | 74 void AddShortcutUsingFavicon(); |
75 | 75 |
76 // Callback run when a favicon is received from GetFavicon() call. | 76 // Callback run when a favicon is received from GetFavicon() call. |
77 void OnDidGetFavicon( | 77 void OnDidGetFavicon( |
78 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 78 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
79 | 79 |
80 // WebContentsObserver | 80 // WebContentsObserver |
81 virtual bool OnMessageReceived(const IPC::Message& message) override; | 81 bool OnMessageReceived(const IPC::Message& message) override; |
82 virtual void WebContentsDestroyed() override; | 82 void WebContentsDestroyed() override; |
83 | 83 |
84 // Adds a shortcut to the launcher using a FaviconRawBitmapResult. | 84 // Adds a shortcut to the launcher using a FaviconRawBitmapResult. |
85 // Must be called from a WorkerPool task. | 85 // Must be called from a WorkerPool task. |
86 static void AddShortcutInBackgroundWithRawBitmap( | 86 static void AddShortcutInBackgroundWithRawBitmap( |
87 const ShortcutInfo& info, | 87 const ShortcutInfo& info, |
88 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 88 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
89 | 89 |
90 // Adds a shortcut to the launcher using a SkBitmap. | 90 // Adds a shortcut to the launcher using a SkBitmap. |
91 // Must be called from a WorkerPool task. | 91 // Must be called from a WorkerPool task. |
92 static void AddShortcutInBackgroundWithSkBitmap( | 92 static void AddShortcutInBackgroundWithSkBitmap( |
93 const ShortcutInfo& info, | 93 const ShortcutInfo& info, |
94 const SkBitmap& icon_bitmap); | 94 const SkBitmap& icon_bitmap); |
95 | 95 |
96 // Registers JNI hooks. | 96 // Registers JNI hooks. |
97 static bool RegisterShortcutHelper(JNIEnv* env); | 97 static bool RegisterShortcutHelper(JNIEnv* env); |
98 | 98 |
99 private: | 99 private: |
100 enum ManifestIconStatus { | 100 enum ManifestIconStatus { |
101 MANIFEST_ICON_STATUS_NONE, | 101 MANIFEST_ICON_STATUS_NONE, |
102 MANIFEST_ICON_STATUS_FETCHING, | 102 MANIFEST_ICON_STATUS_FETCHING, |
103 MANIFEST_ICON_STATUS_DONE | 103 MANIFEST_ICON_STATUS_DONE |
104 }; | 104 }; |
105 | 105 |
106 virtual ~ShortcutHelper(); | 106 ~ShortcutHelper() override; |
107 | 107 |
108 void Destroy(); | 108 void Destroy(); |
109 | 109 |
110 JavaObjectWeakGlobalRef java_ref_; | 110 JavaObjectWeakGlobalRef java_ref_; |
111 | 111 |
112 ShortcutInfo shortcut_info_; | 112 ShortcutInfo shortcut_info_; |
113 SkBitmap manifest_icon_; | 113 SkBitmap manifest_icon_; |
114 base::CancelableTaskTracker cancelable_task_tracker_; | 114 base::CancelableTaskTracker cancelable_task_tracker_; |
115 | 115 |
116 bool add_shortcut_requested_; | 116 bool add_shortcut_requested_; |
117 | 117 |
118 ManifestIconStatus manifest_icon_status_; | 118 ManifestIconStatus manifest_icon_status_; |
119 const int preferred_icon_size_in_px_; | 119 const int preferred_icon_size_in_px_; |
120 static const int kPreferredIconSizeInDp; | 120 static const int kPreferredIconSizeInDp; |
121 | 121 |
122 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; | 122 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 124 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
125 }; | 125 }; |
126 | 126 |
127 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 127 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |