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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1148163003: Allow only responsive websites to install as a web app on mobile. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Preventing unintended method hiding Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/banners/app_banner_data_fetcher.h" 5 #include "chrome/browser/banners/app_banner_data_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/banners/app_banner_debug_log.h" 10 #include "chrome/browser/banners/app_banner_debug_log.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // static 63 // static
64 void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) { 64 void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) {
65 gTimeDeltaForTesting = base::TimeDelta::FromDays(days); 65 gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
66 } 66 }
67 67
68 AppBannerDataFetcher::AppBannerDataFetcher( 68 AppBannerDataFetcher::AppBannerDataFetcher(
69 content::WebContents* web_contents, 69 content::WebContents* web_contents,
70 base::WeakPtr<Delegate> delegate, 70 base::WeakPtr<Delegate> delegate,
71 int ideal_icon_size) 71 int ideal_icon_size)
72 : WebContentsObserver(web_contents), 72 : WebContentsObserver(web_contents),
73 is_active_(false),
74 is_responsive_(true),
benwells 2015/05/27 05:58:55 I think this can be made cleaner. In particular we
dominickn (DO NOT USE) 2015/06/05 07:42:59 Done, but slightly differently to your suggestion.
73 ideal_icon_size_(ideal_icon_size), 75 ideal_icon_size_(ideal_icon_size),
74 weak_delegate_(delegate), 76 weak_delegate_(delegate),
75 is_active_(false),
76 event_request_id_(-1) { 77 event_request_id_(-1) {
77 } 78 }
78 79
79 void AppBannerDataFetcher::Start(const GURL& validated_url) { 80 void AppBannerDataFetcher::Start(const GURL& validated_url) {
80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
81 82
82 content::WebContents* web_contents = GetWebContents(); 83 content::WebContents* web_contents = GetWebContents();
83 DCHECK(web_contents); 84 DCHECK(web_contents);
84 85
85 is_active_ = true; 86 is_active_ = true;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (weak_delegate_->HandleNonWebApp(platform, application.url, id)) 253 if (weak_delegate_->HandleNonWebApp(platform, application.url, id))
253 return; 254 return;
254 } 255 }
255 } 256 }
256 257
257 if (!IsManifestValidForWebApp(manifest, web_contents)) { 258 if (!IsManifestValidForWebApp(manifest, web_contents)) {
258 Cancel(); 259 Cancel();
259 return; 260 return;
260 } 261 }
261 262
263 if (!is_responsive_) {
264 OutputDeveloperMetaViewportErrorMessage(web_contents,
265 kMetaViewportTagNotResponsive);
266 Cancel();
267 return;
268 }
269
262 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED); 270 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
263 271
264 web_app_data_ = manifest; 272 web_app_data_ = manifest;
265 app_title_ = web_app_data_.name.string(); 273 app_title_ = web_app_data_.name.string();
266 274
267 // Check to see if there is a single service worker controlling this page 275 // Check to see if there is a single service worker controlling this page
268 // and the manifest's start url. 276 // and the manifest's start url.
269 Profile* profile = 277 Profile* profile =
270 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 278 Profile::FromBrowserContext(web_contents->GetBrowserContext());
271 content::StoragePartition* storage_partition = 279 content::StoragePartition* storage_partition =
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return false; 402 return false;
395 } 403 }
396 if (!DoesManifestContainRequiredIcon(manifest)) { 404 if (!DoesManifestContainRequiredIcon(manifest)) {
397 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); 405 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon);
398 return false; 406 return false;
399 } 407 }
400 return true; 408 return true;
401 } 409 }
402 410
403 } // namespace banners 411 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698