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

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

Issue 568823003: Merge Android RetrieveWebappInformation and Extensions GetApplicationInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_manager_content
Patch Set: Created 6 years, 3 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/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/task/cancelable_task_tracker.h" 12 #include "base/task/cancelable_task_tracker.h"
13 #include "chrome/common/web_application_info.h"
13 #include "components/favicon_base/favicon_types.h" 14 #include "components/favicon_base/favicon_types.h"
14 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
15 16
16 namespace content { 17 namespace content {
17 class WebContents; 18 class WebContents;
18 } // namespace content 19 } // namespace content
19 20
20 namespace IPC { 21 namespace IPC {
21 class Message; 22 class Message;
22 } 23 }
23 24
24 class GURL; 25 class GURL;
25 26
26 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's 27 // ShortcutHelper is the C++ counterpart of org.chromium.chrome.browser's
27 // ShortcutHelper in Java. The object is owned by the Java object. It is created 28 // ShortcutHelper in Java. The object is owned by the Java object. It is created
28 // from there via a JNI (Initialize) call and can be destroyed from Java too 29 // from there via a JNI (Initialize) call and can be destroyed from Java too
29 // using TearDown. When the Java implementations calls AddShortcut, it gives up 30 // using TearDown. When the Java implementations calls AddShortcut, it gives up
30 // the ownership of the object. The instance will then destroy itself when done. 31 // the ownership of the object. The instance will then destroy itself when done.
31 class ShortcutHelper : public content::WebContentsObserver { 32 class ShortcutHelper : public content::WebContentsObserver {
32 public: 33 public:
33 enum ShortcutType {
34 APP_SHORTCUT,
35 APP_SHORTCUT_APPLE,
36 BOOKMARK
37 };
38
39 ShortcutHelper(JNIEnv* env, 34 ShortcutHelper(JNIEnv* env,
40 jobject obj, 35 jobject obj,
41 content::WebContents* web_contents); 36 content::WebContents* web_contents);
42 37
43 // Initialize the helper by requesting the information about the page to the 38 // Initialize the helper by requesting the information about the page to the
44 // renderer process. The initialization is asynchronous and 39 // renderer process. The initialization is asynchronous and
45 // OnDidRetrieveWebappInformation is expected to be called when finished. 40 // OnDidRetrieveWebappInformation is expected to be called when finished.
46 void Initialize(); 41 void Initialize();
47 42
48 // Called by the Java counter part to let the object knows that it can destroy 43 // Called by the Java counter part to let the object knows that it can destroy
49 // itself. 44 // itself.
50 void TearDown(JNIEnv* env, jobject obj); 45 void TearDown(JNIEnv* env, jobject obj);
51 46
52 // IPC message received when the initialization is finished. 47 // IPC message received when the initialization is finished.
53 void OnDidRetrieveWebappInformation(bool success, 48 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info);
54 bool is_mobile_webapp_capable,
55 bool is_apple_mobile_webapp_capable,
56 const GURL& expected_url);
57 49
58 // Adds a shortcut to the current URL to the Android home screen. 50 // Adds a shortcut to the current URL to the Android home screen.
59 void AddShortcut(JNIEnv* env, 51 void AddShortcut(JNIEnv* env,
60 jobject obj, 52 jobject obj,
61 jstring title, 53 jstring title,
62 jint launcher_large_icon_size); 54 jint launcher_large_icon_size);
63 55
64 void FinishAddingShortcut( 56 void FinishAddingShortcut(
65 const favicon_base::FaviconRawBitmapResult& bitmap_result); 57 const favicon_base::FaviconRawBitmapResult& bitmap_result);
66 58
67 // WebContentsObserver 59 // WebContentsObserver
68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
69 virtual void WebContentsDestroyed() OVERRIDE; 61 virtual void WebContentsDestroyed() OVERRIDE;
70 62
71 // Adds a shortcut to the launcher. Must be called from a WorkerPool task. 63 // Adds a shortcut to the launcher. Must be called from a WorkerPool task.
72 static void AddShortcutInBackground( 64 static void AddShortcutInBackground(
73 const GURL& url, 65 const GURL& url,
74 const base::string16& title, 66 const base::string16& title,
75 ShortcutType shortcut_type, 67 WebApplicationInfo::MobileCapable mobile_capable,
76 const favicon_base::FaviconRawBitmapResult& bitmap_result); 68 const favicon_base::FaviconRawBitmapResult& bitmap_result);
77 69
78 // Registers JNI hooks. 70 // Registers JNI hooks.
79 static bool RegisterShortcutHelper(JNIEnv* env); 71 static bool RegisterShortcutHelper(JNIEnv* env);
80 72
81 private: 73 private:
82 virtual ~ShortcutHelper(); 74 virtual ~ShortcutHelper();
83 75
84 void Destroy(); 76 void Destroy();
85 77
86 JavaObjectWeakGlobalRef java_ref_; 78 JavaObjectWeakGlobalRef java_ref_;
87 79
88 GURL url_; 80 GURL url_;
89 base::string16 title_; 81 base::string16 title_;
90 int launcher_large_icon_size_; 82 int launcher_large_icon_size_;
91 ShortcutType shortcut_type_; 83 WebApplicationInfo::MobileCapable web_app_capable_;
92 favicon_base::FaviconRawBitmapResult icon_; 84 favicon_base::FaviconRawBitmapResult icon_;
93 base::CancelableTaskTracker cancelable_task_tracker_; 85 base::CancelableTaskTracker cancelable_task_tracker_;
94 86
95 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); 87 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper);
96 }; 88 };
97 89
98 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 90 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698