OLD | NEW |
---|---|
(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. | |
pkotwicz
2016/07/13 21:01:16
I started putting C++ files in chrome/browser/andr
Xi Han
2016/07/15 19:30:02
Missed this comment last time, moved now.
| |
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 | |
pkotwicz
2016/07/13 21:01:16
Nit: We do not add comments for forward declaratio
Xi Han
2016/07/15 19:30:02
Done.
| |
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(). | |
pkotwicz
2016/07/13 21:01:16
Nit: Remove "The object is owned by the Java objec
Xi Han
2016/07/15 19:30:02
Done.
| |
28 class ManifestUpgradeDetector : public content::WebContentsObserver { | |
29 public: | |
pkotwicz
2016/07/13 21:01:15
Can the constructor be private?
Xi Han
2016/07/15 19:30:02
It can't, because it is called by the jni function
pkotwicz
2016/07/16 00:56:45
Yes, I see now. I thought that Initialize() was a
Xi Han
2016/07/18 21:49:39
Acknowledged.
| |
30 ManifestUpgradeDetector(JNIEnv* env, | |
31 jobject obj, | |
32 content::WebContents* web_contents, | |
pkotwicz
2016/07/13 21:01:16
Nit: switch the order of |web_manifest_url| and |s
Xi Han
2016/07/15 19:30:02
As discussed offline, keep this order for now:)
| |
33 const GURL& scope, | |
34 const GURL& web_manifest_url); | |
35 | |
36 // Observes a new WebContents, if necessary. | |
pkotwicz
2016/07/13 21:01:16
How about: "Replaces the WebContents that is being
Xi Han
2016/07/15 19:30:02
Done.
| |
37 void ReplaceWebContents( | |
38 JNIEnv* env, | |
39 const base::android::JavaParamRef<jobject>& obj, | |
40 const base::android::JavaParamRef<jobject>& jweb_contents); | |
41 | |
42 // Called by the Java counterpart to destroy its native half. | |
43 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
44 | |
45 // Called by the Java counterpart to start checking web manifest changes. | |
46 void Start(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
47 | |
48 // Registers JNI hooks. | |
49 static bool Register(JNIEnv* env); | |
50 | |
51 // Called when the Manifest has been parsed, or if no Manifest was found. | |
52 void OnDidGetManifest(const GURL& manifest_url, | |
53 const content::Manifest& manifest); | |
54 private: | |
55 ~ManifestUpgradeDetector() override; | |
56 | |
57 // content::WebContentsObserver. | |
pkotwicz
2016/07/13 21:01:15
Nit: "content::WebContentsObserver." -> "content::
Xi Han
2016/07/15 19:30:02
Done.
| |
58 void DidFinishLoad(content::RenderFrameHost* render_frame_host, | |
59 const GURL& validated_url) override; | |
60 | |
61 void OnDataAvailable(const ShortcutInfo& info, | |
62 const std::vector<std::string>& icon_urls); | |
63 | |
64 // Points to the Java object. | |
65 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | |
66 | |
pkotwicz
2016/07/13 21:01:16
Nit: |start_| -> |started_|
Xi Han
2016/07/15 19:30:02
Done.
| |
67 bool start_; | |
68 | |
69 const GURL scope_; | |
70 const GURL web_manifest_url_; | |
71 | |
72 base::WeakPtrFactory<ManifestUpgradeDetector> weak_ptr_factory_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetector); | |
75 }; | |
76 | |
77 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_ | |
OLD | NEW |