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

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: Adding comment explaining using statement Created 5 years, 6 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (weak_delegate_->HandleNonWebApp(platform, application.url, id)) 234 if (weak_delegate_->HandleNonWebApp(platform, application.url, id))
235 return; 235 return;
236 } 236 }
237 } 237 }
238 238
239 if (!IsManifestValidForWebApp(manifest, web_contents)) { 239 if (!IsManifestValidForWebApp(manifest, web_contents)) {
240 Cancel(); 240 Cancel();
241 return; 241 return;
242 } 242 }
243 243
244 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
245
246 web_app_data_ = manifest; 244 web_app_data_ = manifest;
247 app_title_ = web_app_data_.name.string(); 245 app_title_ = web_app_data_.name.string();
248 246
247 HandleWebApp(web_contents);
248 }
249
250 void AppBannerDataFetcher::HandleWebApp(content::WebContents* web_contents) {
251 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
252
249 // Check to see if there is a single service worker controlling this page 253 // Check to see if there is a single service worker controlling this page
250 // and the manifest's start url. 254 // and the manifest's start url.
251 Profile* profile = 255 Profile* profile =
252 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 256 Profile::FromBrowserContext(web_contents->GetBrowserContext());
253 content::StoragePartition* storage_partition = 257 content::StoragePartition* storage_partition =
254 content::BrowserContext::GetStoragePartition( 258 content::BrowserContext::GetStoragePartition(
255 profile, web_contents->GetSiteInstance()); 259 profile, web_contents->GetSiteInstance());
256 DCHECK(storage_partition); 260 DCHECK(storage_partition);
257 261
258 storage_partition->GetServiceWorkerContext()->CheckHasServiceWorker( 262 storage_partition->GetServiceWorkerContext()->CheckHasServiceWorker(
259 validated_url_, manifest.start_url, 263 validated_url_, web_app_data_.start_url,
260 base::Bind(&AppBannerDataFetcher::OnDidCheckHasServiceWorker, 264 base::Bind(&AppBannerDataFetcher::OnDidCheckHasServiceWorker,
261 this)); 265 this));
262 } 266 }
263 267
264 void AppBannerDataFetcher::OnDidCheckHasServiceWorker( 268 void AppBannerDataFetcher::OnDidCheckHasServiceWorker(
265 bool has_service_worker) { 269 bool has_service_worker) {
266 content::WebContents* web_contents = GetWebContents(); 270 content::WebContents* web_contents = GetWebContents();
267 if (!CheckFetcherIsStillAlive(web_contents)) { 271 if (!CheckFetcherIsStillAlive(web_contents)) {
268 Cancel(); 272 Cancel();
269 return; 273 return;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return false; 380 return false;
377 } 381 }
378 if (!DoesManifestContainRequiredIcon(manifest)) { 382 if (!DoesManifestContainRequiredIcon(manifest)) {
379 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); 383 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon);
380 return false; 384 return false;
381 } 385 }
382 return true; 386 return true;
383 } 387 }
384 388
385 } // namespace banners 389 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698