Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / webapps / add_to_homescreen_dialog_helper.h
blob06519a15fdd3a522aa889db234869d39311fcca8
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_weak_ref.h"
10 #include "base/basictypes.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"
15 namespace content {
16 class WebContents;
17 } // namespace content
19 namespace IPC {
20 class Message;
23 class GURL;
25 // AddToHomescreenDialogHelper is the C++ counterpart of
26 // org.chromium.chrome.browser's AddToHomescreenDialogHelper in Java. The object
27 // is owned by the Java object. It is created from there via a JNI (Initialize)
28 // call and MUST BE DESTROYED via Destroy().
29 class AddToHomescreenDialogHelper :
30 public AddToHomescreenDataFetcher::Observer {
31 public:
32 AddToHomescreenDialogHelper(JNIEnv* env,
33 jobject obj,
34 content::WebContents* web_contents,
35 int ideal_splash_image_size_in_dp,
36 int ideal_icon_size_in_dp);
38 // Called by the Java counterpart to destroy its native half.
39 void Destroy(JNIEnv* env, jobject obj);
41 // Registers JNI hooks.
42 static bool RegisterAddToHomescreenDialogHelper(JNIEnv* env);
44 // Adds a shortcut to the current URL to the Android home screen.
45 void AddShortcut(JNIEnv* env, jobject obj, jstring title);
47 // AddToHomescreenDataFetcher::Observer
48 void OnUserTitleAvailable(const base::string16& user_title) override;
49 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon) override;
50 SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, const GURL& url) override;
52 private:
53 virtual ~AddToHomescreenDialogHelper();
55 // Called only when the AddToHomescreenDataFetcher has retrieved all of the
56 // data needed to add the shortcut.
57 void AddShortcut(const ShortcutInfo& info, const SkBitmap& icon);
59 void RecordAddToHomescreen();
61 // Points to the Java object.
62 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
64 // Whether the user has requested that a shortcut be added while a fetch was
65 // in progress.
66 bool add_shortcut_pending_;
68 // Fetches data required to add a shortcut.
69 scoped_refptr<AddToHomescreenDataFetcher> data_fetcher_;
71 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDialogHelper);
74 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_