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

Unified 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: Introduce manifest upgrade detector. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapps/manifest_upgrade_detector.h
diff --git a/chrome/browser/android/webapps/manifest_upgrade_detector.h b/chrome/browser/android/webapps/manifest_upgrade_detector.h
new file mode 100644
index 0000000000000000000000000000000000000000..8fd8e323f05f90d9ca14d50d2a723ca22cb381bb
--- /dev/null
+++ b/chrome/browser/android/webapps/manifest_upgrade_detector.h
@@ -0,0 +1,85 @@
+// 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_MANIFEST_UPGRADE_DETECTOR_H_
+#define CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_
+
+#include <vector>
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_weak_ref.h"
+#include "base/macros.h"
+#include "chrome/browser/android/shortcut_info.h"
+#include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h"
+#include "content/public/common/manifest.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+namespace IPC {
+class Message;
+}
+
+class GURL;
+
+// ManifestUpgradeDetector is the C++ counterpart of
+// org.chromium.chrome.browser's ManifestUpgradeDetector 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 ManifestUpgradeDetector :
+ public content::WebContentsObserver,
+ public AddToHomescreenDataFetcher::Observer {
+ public:
+ ManifestUpgradeDetector(JNIEnv* env,
+ jobject obj,
+ content::WebContents* web_contents);
+
+ // Observes a new WebContents, if necessary.
+ void ReplaceWebContents(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ const base::android::JavaParamRef<jobject>& jweb_contents);
+
+ // Called by the Java counterpart to destroy its native half.
+ void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
+
+ // Called by the Java counterpart to start checking web manifest changes.
+ void Start(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
+
+ // Registers JNI hooks.
+ static bool Register(JNIEnv* env);
+
+ // AddToHomescreenDataFetcher::Observer.
+ void OnDidHasManifest(bool has_manifest) override;
+ void OnDataAvailable(const ShortcutInfo& info,
+ const SkBitmap& icon,
+ const std::vector<std::string>& icon_urls) override;
+ void OnUserTitleAvailable(const base::string16& user_title) override {}
+ SkBitmap FinalizeLauncherIcon(const SkBitmap& icon,
+ const GURL& url,
+ bool* is_generated) override;
+ private:
+ ~ManifestUpgradeDetector() override;
+
+ // content::WebContentsObserver.
+ void DidFinishLoad(content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url) override;
+
+ void RequestDetector(const GURL& validated_url);
+
+ AddToHomescreenDataFetcher* CreateDataFetcher();
+
+ // Points to the Java object.
+ base::android::ScopedJavaGlobalRef<jobject> java_ref_;
+
+ bool start_fetching_;
+
+ // Fetches data required to add a shortcut.
+ scoped_refptr<AddToHomescreenDataFetcher> data_fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetector);
+};
+
+#endif // CHROME_BROWSER_ANDROID_WEBAPPS_MANIFEST_UPGRADE_DETECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698