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

Side by Side Diff: chrome/browser/installable/installable_manager.cc

Issue 2751343002: Adds a basic offline check to InstallableManager. (Closed)
Patch Set: Rebase Created 3 years, 9 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 #include "chrome/browser/installable/installable_manager.h" 5 #include "chrome/browser/installable/installable_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/manifest/manifest_icon_downloader.h" 10 #include "chrome/browser/manifest/manifest_icon_downloader.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 405 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
406 web_contents->GetSiteInstance()); 406 web_contents->GetSiteInstance());
407 DCHECK(storage_partition); 407 DCHECK(storage_partition);
408 408
409 storage_partition->GetServiceWorkerContext()->CheckHasServiceWorker( 409 storage_partition->GetServiceWorkerContext()->CheckHasServiceWorker(
410 web_contents->GetLastCommittedURL(), manifest().start_url, 410 web_contents->GetLastCommittedURL(), manifest().start_url,
411 base::Bind(&InstallableManager::OnDidCheckHasServiceWorker, 411 base::Bind(&InstallableManager::OnDidCheckHasServiceWorker,
412 weak_factory_.GetWeakPtr())); 412 weak_factory_.GetWeakPtr()));
413 } 413 }
414 414
415 void InstallableManager::OnDidCheckHasServiceWorker(bool has_service_worker) { 415 void InstallableManager::OnDidCheckHasServiceWorker(
416 content::ServiceWorkerCapability capability) {
416 if (!GetWebContents()) 417 if (!GetWebContents())
417 return; 418 return;
418 419
419 if (has_service_worker) { 420 switch (capability) {
420 installable_->installable = true; 421 case content::ServiceWorkerCapability::SERVICE_WORKER_WITH_FETCH_HANDLER:
421 } else { 422 installable_->installable = true;
422 installable_->installable = false; 423 break;
423 installable_->error = NO_MATCHING_SERVICE_WORKER; 424 case content::ServiceWorkerCapability::SERVICE_WORKER_NO_FETCH_HANDLER:
425 installable_->installable = false;
426 installable_->error = NOT_OFFLINE_CAPABLE;
427 break;
428 case content::ServiceWorkerCapability::NO_SERVICE_WORKER:
429 installable_->installable = false;
430 installable_->error = NO_MATCHING_SERVICE_WORKER;
431 break;
424 } 432 }
425 433
426 installable_->fetched = true; 434 installable_->fetched = true;
427 WorkOnTask(); 435 WorkOnTask();
428 } 436 }
429 437
430 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) { 438 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) {
431 DCHECK(!manifest().IsEmpty()); 439 DCHECK(!manifest().IsEmpty());
432 440
433 int ideal_icon_size_in_px = std::get<0>(params); 441 int ideal_icon_size_in_px = std::get<0>(params);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return manifest_->url; 499 return manifest_->url;
492 } 500 }
493 501
494 const content::Manifest& InstallableManager::manifest() const { 502 const content::Manifest& InstallableManager::manifest() const {
495 return manifest_->manifest; 503 return manifest_->manifest;
496 } 504 }
497 505
498 bool InstallableManager::is_installable() const { 506 bool InstallableManager::is_installable() const {
499 return installable_->installable; 507 return installable_->installable;
500 } 508 }
OLDNEW
« no previous file with comments | « chrome/browser/installable/installable_manager.h ('k') | chrome/browser/installable/installable_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698