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

Side by Side Diff: chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.h

Issue 2331773002: Take Murmur2 hash of untransformed icon when creating WebAPK part 2/2 (Closed)
Patch Set: Merge branch 'master' into icon_hasher2 Created 4 years, 3 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
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 "chrome/browser/android/shortcut_info.h"
12 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 #include "third_party/skia/include/core/SkBitmap.h"
13 15
14 namespace content { 16 namespace content {
15 struct Manifest; 17 struct Manifest;
16 class WebContents; 18 class WebContents;
17 } 19 }
18 20
19 class GURL; 21 class GURL;
20 class SkBitmap;
21 struct InstallableData; 22 struct InstallableData;
22 struct ShortcutInfo; 23 class WebApkIconHasher;
23 24
24 // ManifestUpgradeDetectorFetcher is the C++ counterpart of 25 // ManifestUpgradeDetectorFetcher is the C++ counterpart of
25 // org.chromium.chrome.browser's ManifestUpgradeDetectorFetcher in Java. It is 26 // org.chromium.chrome.browser's ManifestUpgradeDetectorFetcher in Java. It is
26 // created via a JNI (Initialize) call and MUST BE DESTROYED via Destroy(). 27 // created via a JNI (Initialize) call and MUST BE DESTROYED via Destroy().
27 class ManifestUpgradeDetectorFetcher : public content::WebContentsObserver { 28 class ManifestUpgradeDetectorFetcher : public content::WebContentsObserver {
28 public: 29 public:
29 ManifestUpgradeDetectorFetcher(JNIEnv* env, 30 ManifestUpgradeDetectorFetcher(JNIEnv* env,
30 jobject obj, 31 jobject obj,
31 const GURL& scope, 32 const GURL& scope,
32 const GURL& web_manifest_url); 33 const GURL& web_manifest_url);
(...skipping 18 matching lines...) Expand all
51 private: 52 private:
52 ~ManifestUpgradeDetectorFetcher() override; 53 ~ManifestUpgradeDetectorFetcher() override;
53 54
54 // content::WebContentsObserver: 55 // content::WebContentsObserver:
55 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 56 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
56 const GURL& validated_url) override; 57 const GURL& validated_url) override;
57 58
58 // Called once the installable data has been fetched. 59 // Called once the installable data has been fetched.
59 void OnDidGetInstallableData(const InstallableData& installable_data); 60 void OnDidGetInstallableData(const InstallableData& installable_data);
60 61
61 void OnDataAvailable(const ShortcutInfo& info, const SkBitmap& icon); 62 // Called with the computed Murmur2 hash for the app icon.
63 void OnGotIconMurmur2Hash(const std::string& icon_murmur2_hash);
64
65 void OnDataAvailable(const ShortcutInfo& info,
66 const std::string& icon_murmur2_hash,
67 const SkBitmap& icon);
62 68
63 // Points to the Java object. 69 // Points to the Java object.
64 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 70 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
65 71
66 // The detector will only fetch the URL within the scope of the WebAPK. 72 // The detector will only fetch the URL within the scope of the WebAPK.
67 const GURL scope_; 73 const GURL scope_;
68 74
69 // The WebAPK's Web Manifest URL that the detector is looking for. 75 // The WebAPK's Web Manifest URL that the detector is looking for.
70 const GURL web_manifest_url_; 76 const GURL web_manifest_url_;
71 77
78 // Downloads app icon and computes Murmur2 hash.
79 std::unique_ptr<WebApkIconHasher> icon_hasher_;
80
81 // Downloaded data for |web_manifest_url_|.
82 ShortcutInfo info_;
83 SkBitmap icon_;
84
72 base::WeakPtrFactory<ManifestUpgradeDetectorFetcher> weak_ptr_factory_; 85 base::WeakPtrFactory<ManifestUpgradeDetectorFetcher> weak_ptr_factory_;
73 86
74 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetectorFetcher); 87 DISALLOW_COPY_AND_ASSIGN(ManifestUpgradeDetectorFetcher);
75 }; 88 };
76 89
77 #endif // CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_ 90 #endif // CHROME_BROWSER_ANDROID_WEBAPK_MANIFEST_UPGRADE_DETECTOR_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698