| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ | 6 #define CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 struct Manifest; | 15 struct Manifest; |
| 16 class WebContents; | 16 class WebContents; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 class SkBitmap; |
| 21 struct InstallableData; |
| 20 struct ShortcutInfo; | 22 struct ShortcutInfo; |
| 21 | 23 |
| 22 // ManifestUpgradeDetectorFetcher is the C++ counterpart of | 24 // ManifestUpgradeDetectorFetcher is the C++ counterpart of |
| 23 // org.chromium.chrome.browser's ManifestUpgradeDetectorFetcher in Java. It is | 25 // org.chromium.chrome.browser's ManifestUpgradeDetectorFetcher in Java. It is |
| 24 // created via a JNI (Initialize) call and MUST BE DESTROYED via Destroy(). | 26 // created via a JNI (Initialize) call and MUST BE DESTROYED via Destroy(). |
| 25 class ManifestUpgradeDetectorFetcher : public content::WebContentsObserver { | 27 class ManifestUpgradeDetectorFetcher : public content::WebContentsObserver { |
| 26 public: | 28 public: |
| 27 ManifestUpgradeDetectorFetcher(JNIEnv* env, | 29 ManifestUpgradeDetectorFetcher(JNIEnv* env, |
| 28 jobject obj, | 30 jobject obj, |
| 29 const GURL& scope, | 31 const GURL& scope, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 46 // Registers JNI hooks. | 48 // Registers JNI hooks. |
| 47 static bool Register(JNIEnv* env); | 49 static bool Register(JNIEnv* env); |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 ~ManifestUpgradeDetectorFetcher() override; | 52 ~ManifestUpgradeDetectorFetcher() override; |
| 51 | 53 |
| 52 // content::WebContentsObserver: | 54 // content::WebContentsObserver: |
| 53 void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 55 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 54 const GURL& validated_url) override; | 56 const GURL& validated_url) override; |
| 55 | 57 |
| 56 // Called when the Manifest has been parsed, or if no Manifest was found. | 58 // Called once the installable data has been fetched. |
| 57 void OnDidGetManifest(const GURL& manifest_url, | 59 void OnDidGetInstallableData(const InstallableData& installable_data); |
| 58 const content::Manifest& manifest); | |
| 59 | 60 |
| 60 void OnDataAvailable(const ShortcutInfo& info); | 61 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon); |
| 61 | 62 |
| 62 // Points to the Java object. | 63 // Points to the Java object. |
| 63 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 64 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 64 | 65 |
| 65 // The detector will only fetch the URL within the scope of the WebAPK. | 66 // The detector will only fetch the URL within the scope of the WebAPK. |
| 66 const GURL scope_; | 67 const GURL scope_; |
| 67 | 68 |
| 68 // The WebAPK's Web Manifest URL that the detector is looking for. | 69 // The WebAPK's Web Manifest URL that the detector is looking for. |
| 69 const GURL web_manifest_url_; | 70 const GURL web_manifest_url_; |
| 70 | 71 |
| 71 base::WeakPtrFactory<ManifestUpgradeDetectorFetcher> weak_ptr_factory_; | 72 base::WeakPtrFactory<ManifestUpgradeDetectorFetcher> weak_ptr_factory_; |
| 72 | 73 |
| 73 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetectorFetcher); | 74 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetectorFetcher); |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 #endif // CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ | 77 #endif // CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ |
| OLD | NEW |