Index: chrome/browser/android/webapps/add_to_homescreen_manager.h |
diff --git a/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h b/chrome/browser/android/webapps/add_to_homescreen_manager.h |
similarity index 49% |
copy from chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h |
copy to chrome/browser/android/webapps/add_to_homescreen_manager.h |
index 4780185c021dc67a9e47803416a3e31c7c6b4630..39953335ee1b711fd696ade143ce58d8a6bf0f3f 100644 |
--- a/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h |
+++ b/chrome/browser/android/webapps/add_to_homescreen_manager.h |
@@ -1,15 +1,15 @@ |
-// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_ |
-#define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_ |
+#ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_MANAGER_H_ |
+#define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_MANAGER_H_ |
#include "base/android/jni_android.h" |
#include "base/android/scoped_java_ref.h" |
#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
#include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
-#include "third_party/skia/include/core/SkBitmap.h" |
namespace content { |
class WebContents; |
@@ -20,21 +20,20 @@ class Message; |
} |
class GURL; |
+class SkBitmap; |
+struct InstallableData; |
struct ShortcutInfo; |
-// AddToHomescreenDialogHelper is the C++ counterpart of |
-// org.chromium.chrome.browser's AddToHomescreenDialogHelper in Java. The object |
-// is owned by the Java object. It is created from there via a JNI (Initialize) |
-// call and MUST BE DESTROYED via Destroy(). |
-class AddToHomescreenDialogHelper : |
- public AddToHomescreenDataFetcher::Observer { |
+// AddToHomescreenManager is the C++ counterpart of |
+// org.chromium.chrome.browser's AddToHomescreenManager in Java. The object |
+// is owned by the Java object. It is created from there via a JNI |
+// (InitializeAndStart) call and MUST BE DESTROYED via Destroy(). |
+class AddToHomescreenManager : public AddToHomescreenDataFetcher::Observer { |
public: |
- // Registers JNI hooks. |
- static bool RegisterAddToHomescreenDialogHelper(JNIEnv* env); |
+ AddToHomescreenManager(JNIEnv* env, jobject obj); |
- AddToHomescreenDialogHelper(JNIEnv* env, |
- jobject obj, |
- content::WebContents* web_contents); |
+ // Registers JNI hooks. |
+ static bool Register(JNIEnv* env); |
// Called by the Java counterpart to destroy its native half. |
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
@@ -44,8 +43,32 @@ class AddToHomescreenDialogHelper : |
const base::android::JavaParamRef<jobject>& obj, |
const base::android::JavaParamRef<jstring>& title); |
+ // Starts add-to-homescreen process. |
+ void Start(content::WebContents* web_contents); |
+ |
private: |
- virtual ~AddToHomescreenDialogHelper(); |
+ ~AddToHomescreenManager() override; |
+ |
+ // Checks whether the current page in |web_contents| can be made into a |
+ // WebAPK. |
+ void CheckWebApkCompatible(content::WebContents* web_contents); |
+ |
+ // Called once the request for "installability data" started by |
+ // CheckWebApkCompatible() has completed. |
+ void OnGotWebApkCompatibilityData(content::WebContents* web_contents, |
+ const InstallableData& installable_data); |
+ |
+ // Called once it has been determined whether the current page in |
+ // |web_contents| can be made into a WebAPK. |
+ void OnDeterminedWebApkCompatibility(content::WebContents* web_contents, |
+ bool is_compatible); |
+ |
+ // Shows alert to prompt user for name of home screen shortcut. |
+ void ShowDialog(); |
+ |
+ // Starts fetching home screen shortcut data (like Web Manifest and home |
+ // screen icon). |
+ void StartFetchingInfoForShortcut(content::WebContents* web_contents); |
// Called only when the AddToHomescreenDataFetcher has retrieved all of the |
// data needed to add the shortcut. |
@@ -70,7 +93,9 @@ class AddToHomescreenDialogHelper : |
// Fetches data required to add a shortcut. |
scoped_refptr<AddToHomescreenDataFetcher> data_fetcher_; |
- DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDialogHelper); |
+ base::WeakPtrFactory<AddToHomescreenManager> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AddToHomescreenManager); |
}; |
-#endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DIALOG_HELPER_H_ |
+#endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_MANAGER_H_ |