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

Side by Side Diff: chrome/browser/android/banners/app_banner_manager.cc

Issue 946573002: AppBanner: add requirement for an 144x144 image/png icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/banners/app_banner_manager.h" 5 #include "chrome/browser/android/banners/app_banner_manager.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_util.h"
12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" 13 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h"
13 #include "chrome/browser/android/manifest_icon_selector.h" 14 #include "chrome/browser/android/manifest_icon_selector.h"
14 #include "chrome/browser/android/shortcut_helper.h" 15 #include "chrome/browser/android/shortcut_helper.h"
15 #include "chrome/browser/android/shortcut_info.h" 16 #include "chrome/browser/android/shortcut_info.h"
16 #include "chrome/browser/banners/app_banner_metrics.h" 17 #include "chrome/browser/banners/app_banner_metrics.h"
17 #include "chrome/browser/banners/app_banner_settings_helper.h" 18 #include "chrome/browser/banners/app_banner_settings_helper.h"
18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 19 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
19 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/metrics/rappor/sampling.h" 21 #include "chrome/browser/metrics/rappor/sampling.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
(...skipping 14 matching lines...) Expand all
36 #include "net/base/load_flags.h" 37 #include "net/base/load_flags.h"
37 #include "ui/gfx/android/java_bitmap.h" 38 #include "ui/gfx/android/java_bitmap.h"
38 #include "ui/gfx/screen.h" 39 #include "ui/gfx/screen.h"
39 40
40 using base::android::ConvertJavaStringToUTF8; 41 using base::android::ConvertJavaStringToUTF8;
41 using base::android::ConvertJavaStringToUTF16; 42 using base::android::ConvertJavaStringToUTF16;
42 using base::android::ConvertUTF8ToJavaString; 43 using base::android::ConvertUTF8ToJavaString;
43 using base::android::ConvertUTF16ToJavaString; 44 using base::android::ConvertUTF16ToJavaString;
44 45
45 namespace { 46 namespace {
47
46 const char kBannerTag[] = "google-play-id"; 48 const char kBannerTag[] = "google-play-id";
47 base::TimeDelta gTimeDeltaForTesting; 49 base::TimeDelta gTimeDeltaForTesting;
48 bool gDisableSecureCheckForTesting = false; 50 bool gDisableSecureCheckForTesting = false;
49 } // namespace 51
52 // The requirement for now is an image/png that is at least 144x144.
53 bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) {
54 for (const auto& icon : manifest.icons) {
55 if (EqualsASCII(icon.type.string(), "image/png"))
56 continue;
57
58 for (const auto& size : icon.sizes) {
59 if (size.IsEmpty()) // "any"
60 return true;
61 if (size.width() >= 144 && size.height() >= 144)
gone 2015/02/20 17:36:41 Make 144 a constant up above.
62 return true;
63 }
64 }
65
66 return false;
67 }
68
69 } // anonymous namespace
50 70
51 namespace banners { 71 namespace banners {
52 72
53 // Fetches a bitmap and deletes itself when completed. 73 // Fetches a bitmap and deletes itself when completed.
54 class AppBannerManager::BannerBitmapFetcher 74 class AppBannerManager::BannerBitmapFetcher
55 : public chrome::BitmapFetcher, 75 : public chrome::BitmapFetcher,
56 public chrome::BitmapFetcherDelegate { 76 public chrome::BitmapFetcherDelegate {
57 public: 77 public:
58 BannerBitmapFetcher(const GURL& image_url, 78 BannerBitmapFetcher(const GURL& image_url,
59 banners::AppBannerManager* manager); 79 banners::AppBannerManager* manager);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 web_contents()->GetManifest(base::Bind(&AppBannerManager::OnDidGetManifest, 163 web_contents()->GetManifest(base::Bind(&AppBannerManager::OnDidGetManifest,
144 weak_factory_.GetWeakPtr())); 164 weak_factory_.GetWeakPtr()));
145 } 165 }
146 166
147 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) { 167 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) {
148 if (web_contents()->IsBeingDestroyed()) 168 if (web_contents()->IsBeingDestroyed())
149 return; 169 return;
150 170
151 if (manifest.IsEmpty() 171 if (manifest.IsEmpty()
152 || !manifest.start_url.is_valid() 172 || !manifest.start_url.is_valid()
153 || (manifest.name.is_null() && manifest.short_name.is_null())) { 173 || (manifest.name.is_null() && manifest.short_name.is_null())
174 || !DoesManifestContainRequiredIcon(manifest)) {
154 // No usable manifest, see if there is a play store meta tag. 175 // No usable manifest, see if there is a play store meta tag.
155 Send(new ChromeViewMsg_RetrieveMetaTagContent(routing_id(), 176 Send(new ChromeViewMsg_RetrieveMetaTagContent(routing_id(),
156 validated_url_, 177 validated_url_,
157 kBannerTag)); 178 kBannerTag));
158 return; 179 return;
159 } 180 }
160 181
161 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED); 182 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
162 183
163 web_app_data_ = manifest; 184 web_app_data_ = manifest;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) { 403 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) {
383 gDisableSecureCheckForTesting = true; 404 gDisableSecureCheckForTesting = true;
384 } 405 }
385 406
386 // Register native methods 407 // Register native methods
387 bool RegisterAppBannerManager(JNIEnv* env) { 408 bool RegisterAppBannerManager(JNIEnv* env) {
388 return RegisterNativesImpl(env); 409 return RegisterNativesImpl(env);
389 } 410 }
390 411
391 } // namespace banners 412 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698