| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // Adds a shortcut to the current URL to the Android home screen. | 40 // Adds a shortcut to the current URL to the Android home screen. |
| 41 void AddShortcut(JNIEnv* env, jobject obj, jstring title); | 41 void AddShortcut(JNIEnv* env, jobject obj, jstring title); |
| 42 | 42 |
| 43 // Adds a shortcut to the launcher using a SkBitmap. | 43 // Adds a shortcut to the launcher using a SkBitmap. |
| 44 // Must be called on the IO thread. | 44 // Must be called on the IO thread. |
| 45 static void AddShortcutInBackgroundWithSkBitmap(const ShortcutInfo& info, | 45 static void AddShortcutInBackgroundWithSkBitmap(const ShortcutInfo& info, |
| 46 const SkBitmap& icon_bitmap); | 46 const SkBitmap& icon_bitmap); |
| 47 | 47 |
| 48 // ShortcutDataFetcher::Observer | 48 // ShortcutDataFetcher::Observer |
| 49 void OnTitleAvailable(const base::string16& title) override; | 49 void OnUserTitleAvailable(const base::string16& user_title) override; |
| 50 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon) override; | 50 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon) override; |
| 51 SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, const GURL& url) override; | 51 SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, const GURL& url) override; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 virtual ~ShortcutHelper(); | 54 virtual ~ShortcutHelper(); |
| 55 | 55 |
| 56 // Called only when the ShortcutDataFetcher has retrieved all of the | 56 // Called only when the ShortcutDataFetcher has retrieved all of the |
| 57 // data needed to add the shortcut. | 57 // data needed to add the shortcut. |
| 58 void AddShortcut(const ShortcutInfo& info, const SkBitmap& icon); | 58 void AddShortcut(const ShortcutInfo& info, const SkBitmap& icon); |
| 59 | 59 |
| 60 void RecordAddToHomescreen(); | 60 void RecordAddToHomescreen(); |
| 61 | 61 |
| 62 // Points to the Java object. | 62 // Points to the Java object. |
| 63 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 63 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 64 | 64 |
| 65 // Whether the user has requested that a shortcut be added while a fetch was | 65 // Whether the user has requested that a shortcut be added while a fetch was |
| 66 // in progress. | 66 // in progress. |
| 67 bool add_shortcut_pending_; | 67 bool add_shortcut_pending_; |
| 68 | 68 |
| 69 // Fetches data required to add a shortcut. | 69 // Fetches data required to add a shortcut. |
| 70 scoped_refptr<ShortcutDataFetcher> data_fetcher_; | 70 scoped_refptr<ShortcutDataFetcher> data_fetcher_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 72 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 75 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |