Chromium Code Reviews| 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 #include "chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.h" | 5 #include "chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "chrome/browser/android/shortcut_helper.h" | 11 #include "chrome/browser/android/shortcut_helper.h" |
| 12 #include "chrome/browser/android/shortcut_info.h" | 12 #include "chrome/browser/android/shortcut_info.h" |
| 13 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" | |
| 13 #include "chrome/browser/installable/installable_manager.h" | 14 #include "chrome/browser/installable/installable_manager.h" |
| 14 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/manifest.h" | 17 #include "content/public/common/manifest.h" |
| 17 #include "jni/ManifestUpgradeDetectorFetcher_jni.h" | 18 #include "jni/ManifestUpgradeDetectorFetcher_jni.h" |
| 18 #include "third_party/smhasher/src/MurmurHash2.h" | 19 #include "third_party/smhasher/src/MurmurHash2.h" |
| 19 #include "ui/gfx/android/java_bitmap.h" | 20 #include "ui/gfx/android/java_bitmap.h" |
| 20 #include "ui/gfx/codec/png_codec.h" | 21 #include "ui/gfx/codec/png_codec.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 // links to the Web Manifest that we are looking for. | 129 // links to the Web Manifest that we are looking for. |
| 129 // If the manifest URL is different from the current one, we will continue | 130 // If the manifest URL is different from the current one, we will continue |
| 130 // observing too. It is based on our assumption that it is invalid for | 131 // observing too. It is based on our assumption that it is invalid for |
| 131 // web developers to change the Web Manifest location. When it does | 132 // web developers to change the Web Manifest location. When it does |
| 132 // change, we will treat the new Web Manifest as the one of another WebAPK. | 133 // change, we will treat the new Web Manifest as the one of another WebAPK. |
| 133 if (data.manifest.IsEmpty() || web_manifest_url_ != data.manifest_url) | 134 if (data.manifest.IsEmpty() || web_manifest_url_ != data.manifest_url) |
| 134 return; | 135 return; |
| 135 | 136 |
| 136 // TODO(pkotwicz): Tell Java side that the Web Manifest was fetched but the | 137 // TODO(pkotwicz): Tell Java side that the Web Manifest was fetched but the |
| 137 // Web Manifest is not WebAPK-compatible. (http://crbug.com/639536) | 138 // Web Manifest is not WebAPK-compatible. (http://crbug.com/639536) |
| 138 if (!data.is_installable) | 139 if (CheckWebManifestUrlsWebApkCompatible(data.manifest) != |
| 140 NO_ERROR_DETECTED) { | |
|
dominickn
2016/08/24 03:27:11
Do you still want to check data.installable here?
pkotwicz
2016/08/24 15:04:56
Yes I do. Thank you for catching this bug!
| |
| 139 return; | 141 return; |
| 142 } | |
| 140 | 143 |
| 141 ShortcutInfo info(GURL::EmptyGURL()); | 144 ShortcutInfo info(GURL::EmptyGURL()); |
| 142 info.UpdateFromManifest(data.manifest); | 145 info.UpdateFromManifest(data.manifest); |
| 143 info.manifest_url = data.manifest_url; | 146 info.manifest_url = data.manifest_url; |
| 144 info.icon_url = data.icon_url; | 147 info.icon_url = data.icon_url; |
| 145 OnDataAvailable(info, (data.icon ? *data.icon : SkBitmap())); | 148 OnDataAvailable(info, (data.icon ? *data.icon : SkBitmap())); |
| 146 } | 149 } |
| 147 | 150 |
| 148 void ManifestUpgradeDetectorFetcher::OnDataAvailable( | 151 void ManifestUpgradeDetectorFetcher::OnDataAvailable( |
| 149 const ShortcutInfo& info, | 152 const ShortcutInfo& info, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 167 // TODO(pkotwicz): Get hash of untransformed icon's bytes (with no | 170 // TODO(pkotwicz): Get hash of untransformed icon's bytes (with no |
| 168 // encoding/decoding). | 171 // encoding/decoding). |
| 169 icon_murmur2_hash = ComputeBitmapHash(icon_bitmap); | 172 icon_murmur2_hash = ComputeBitmapHash(icon_bitmap); |
| 170 } | 173 } |
| 171 | 174 |
| 172 Java_ManifestUpgradeDetectorFetcher_onDataAvailable( | 175 Java_ManifestUpgradeDetectorFetcher_onDataAvailable( |
| 173 env, java_ref_, java_url, java_scope, java_name, java_short_name, | 176 env, java_ref_, java_url, java_scope, java_name, java_short_name, |
| 174 java_icon_url, icon_murmur2_hash, java_bitmap, info.display, | 177 java_icon_url, icon_murmur2_hash, java_bitmap, info.display, |
| 175 info.orientation, info.theme_color, info.background_color); | 178 info.orientation, info.theme_color, info.background_color); |
| 176 } | 179 } |
| OLD | NEW |