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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_helper.h

Issue 1288903002: Refactor ShortcutHelper and merge in BookmarkUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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_WEBAPPS_ADD_TO_HOMESCREEN_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_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"
11 #include "chrome/browser/android/shortcut_data_fetcher.h"
12 #include "chrome/browser/android/shortcut_info.h" 11 #include "chrome/browser/android/shortcut_info.h"
12 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h"
13 #include "content/public/common/manifest.h" 13 #include "content/public/common/manifest.h"
14 14
15 namespace content { 15 namespace content {
16 class WebContents; 16 class WebContents;
17 } // namespace content 17 } // namespace content
18 18
19 namespace IPC { 19 namespace IPC {
20 class Message; 20 class Message;
21 } 21 }
22 22
23 class GURL; 23 class GURL;
24 24
25 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's 25 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's
gone 2015/08/13 20:54:28 you didn't change any of the comments to change th
Lalit Maganti 2015/08/26 13:57:08 Done in https://codereview.chromium.org/1321463002
Lalit Maganti 2015/08/26 13:57:08 Done in later patchset in this series.
26 // ShortcutHelper in Java. The object is owned by the Java object. It is created 26 // ShortcutHelper in Java. The object is owned by the Java object. It is created
27 // from there via a JNI (Initialize) call and MUST BE DESTROYED via Destroy(). 27 // from there via a JNI (Initialize) call and MUST BE DESTROYED via Destroy().
28 class ShortcutHelper : public ShortcutDataFetcher::Observer { 28 class AddToHomescreenHelper : public AddToHomescreenDataFetcher::Observer {
29 public: 29 public:
30 ShortcutHelper(JNIEnv* env, 30 AddToHomescreenHelper(JNIEnv* env,
31 jobject obj, 31 jobject obj,
32 content::WebContents* web_contents); 32 content::WebContents* web_contents);
33 33
34 // Called by the Java counterpart to destroy its native half. 34 // Called by the Java counterpart to destroy its native half.
35 void Destroy(JNIEnv* env, jobject obj); 35 void Destroy(JNIEnv* env, jobject obj);
36 36
37 // Registers JNI hooks. 37 // Registers JNI hooks.
38 static bool RegisterShortcutHelper(JNIEnv* env); 38 static bool RegisterAddToHomescreenHelper(JNIEnv* env);
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 // AddToHomescreenDataFetcher::Observer
44 // Must be called on the IO thread.
45 static void AddShortcutInBackgroundWithSkBitmap(const ShortcutInfo& info,
46 const SkBitmap& icon_bitmap);
47
48 // ShortcutDataFetcher::Observer
49 void OnUserTitleAvailable(const base::string16& user_title) override; 44 void OnUserTitleAvailable(const base::string16& user_title) override;
50 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon) override; 45 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon) override;
51 SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, const GURL& url) override; 46 SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, const GURL& url) override;
52 47
53 private: 48 private:
54 virtual ~ShortcutHelper(); 49 virtual ~AddToHomescreenHelper();
55 50
56 // Called only when the ShortcutDataFetcher has retrieved all of the 51 // Called only when the ShortcutDataFetcher has retrieved all of the
57 // data needed to add the shortcut. 52 // data needed to add the shortcut.
58 void AddShortcut(const ShortcutInfo& info, const SkBitmap& icon); 53 void AddShortcut(const ShortcutInfo& info, const SkBitmap& icon);
59 54
60 void RecordAddToHomescreen(); 55 void RecordAddToHomescreen();
61 56
62 // Points to the Java object. 57 // Points to the Java object.
63 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 58 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
64 59
65 // Whether the user has requested that a shortcut be added while a fetch was 60 // Whether the user has requested that a shortcut be added while a fetch was
66 // in progress. 61 // in progress.
67 bool add_shortcut_pending_; 62 bool add_shortcut_pending_;
68 63
69 // Fetches data required to add a shortcut. 64 // Fetches data required to add a shortcut.
70 scoped_refptr<ShortcutDataFetcher> data_fetcher_; 65 scoped_refptr<AddToHomescreenDataFetcher> data_fetcher_;
71 66
72 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); 67 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenHelper);
73 }; 68 };
74 69
75 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 70 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698