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

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

Issue 2124513002: Introduce ManifestUpgradeDetector for WebAPK to detect web manifest changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove data fetcher and doesn't fetch icon for now. Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_
7
8 #include <vector>
9
10 #include "base/android/jni_android.h"
11 #include "base/android/jni_weak_ref.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "content/public/browser/web_contents_observer.h"
15
16 namespace content {
17 struct Manifest;
18 class WebContents;
19 } // namespace content
20
21 class GURL;
22 struct ShortcutInfo;
23
24 // ManifestUpgradeDetector is the C++ counterpart of
25 // org.chromium.chrome.browser's ManifestUpgradeDetector in Java. The object
26 // is owned by the Java object. It is created from there via a JNI (Initialize)
27 // call and MUST BE DESTROYED via Destroy().
28 class ManifestUpgradeDetector : public content::WebContentsObserver {
29 public:
30 ManifestUpgradeDetector(JNIEnv* env,
31 jobject obj,
32 content::WebContents* web_contents,
33 const GURL& web_manifest_url);
34
35 // Observes a new WebContents, if necessary.
36 void ReplaceWebContents(
37 JNIEnv* env,
38 const base::android::JavaParamRef<jobject>& obj,
39 const base::android::JavaParamRef<jobject>& jweb_contents);
40
41 // Called by the Java counterpart to destroy its native half.
42 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
43
44 // Called by the Java counterpart to start checking web manifest changes.
45 void Start(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
46
47 // Registers JNI hooks.
48 static bool Register(JNIEnv* env);
49
50 // Called when the Manifest has been parsed, or if no Manifest was found.
51 void OnDidGetManifest(const GURL& manifest_url,
52 const content::Manifest& manifest);
53 private:
54 ~ManifestUpgradeDetector() override;
55
56 // content::WebContentsObserver.
57 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
58 const GURL& validated_url) override;
59
60 void OnDataAvailable(const ShortcutInfo& info,
61 const std::vector<std::string>& icon_urls);
62
63 // Points to the Java object.
64 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
65
66 bool start_;
67
68 const GURL web_manifest_url_;
69
70 base::WeakPtrFactory<ManifestUpgradeDetector> weak_ptr_factory_;
71
72 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetector);
73 };
74
75 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698