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

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 1497193002: Remove all the ephemeral apps code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/webstore_private/webstore_private_api.h" 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 icon_url = source_url().Resolve(*details().icon_url); 200 icon_url = source_url().Resolve(*details().icon_url);
201 if (!icon_url.is_valid()) { 201 if (!icon_url.is_valid()) {
202 return RespondNow(BuildResponse( 202 return RespondNow(BuildResponse(
203 api::webstore_private::RESULT_INVALID_ICON_URL, 203 api::webstore_private::RESULT_INVALID_ICON_URL,
204 kInvalidIconUrlError)); 204 kInvalidIconUrlError));
205 } 205 }
206 } 206 }
207 207
208 InstallTracker* tracker = InstallTracker::Get(browser_context()); 208 InstallTracker* tracker = InstallTracker::Get(browser_context());
209 DCHECK(tracker); 209 DCHECK(tracker);
210 if (util::IsExtensionInstalledPermanently(details().id, browser_context()) || 210 bool is_installed =
211 tracker->GetActiveInstall(details().id)) { 211 extensions::ExtensionRegistry::Get(browser_context())->GetExtensionById(
212 details().id, extensions::ExtensionRegistry::EVERYTHING) != nullptr;
213 if (is_installed || tracker->GetActiveInstall(details().id)) {
212 return RespondNow(BuildResponse( 214 return RespondNow(BuildResponse(
213 api::webstore_private::RESULT_ALREADY_INSTALLED, 215 api::webstore_private::RESULT_ALREADY_INSTALLED,
214 kAlreadyInstalledError)); 216 kAlreadyInstalledError));
215 } 217 }
216 ActiveInstallData install_data(details().id); 218 ActiveInstallData install_data(details().id);
217 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); 219 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data));
218 220
219 net::URLRequestContextGetter* context_getter = nullptr; 221 net::URLRequestContextGetter* context_getter = nullptr;
220 if (!icon_url.is_empty()) 222 if (!icon_url.is_empty())
221 context_getter = browser_context()->GetRequestContext(); 223 context_getter = browser_context()->GetRequestContext();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 421
420 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) { 422 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) {
421 // Show the app list to show download is progressing. Don't show the app 423 // Show the app list to show download is progressing. Don't show the app
422 // list on first app install so users can be trained to open it themselves. 424 // list on first app install so users can be trained to open it themselves.
423 app_list_service->ShowForAppInstall( 425 app_list_service->ShowForAppInstall(
424 chrome_details_.GetProfile(), 426 chrome_details_.GetProfile(),
425 params->expected_id, 427 params->expected_id,
426 approval_->enable_launcher); 428 approval_->enable_launcher);
427 } 429 }
428 430
429 // If the target extension has already been installed ephemerally and is
430 // up to date, it can be promoted to a regular installed extension and
431 // downloading from the Web Store is not necessary.
432 const Extension* extension = ExtensionRegistry::Get(browser_context())->
433 GetExtensionById(params->expected_id, ExtensionRegistry::EVERYTHING);
434 if (extension && approval_->dummy_extension.get() &&
435 util::IsEphemeralApp(extension->id(), browser_context()) &&
436 extension->version()->CompareTo(*approval_->dummy_extension->version()) >=
437 0) {
438 install_ui::ShowPostInstallUIForApproval(
439 browser_context(), *approval_, extension);
440
441 ExtensionService* extension_service =
442 ExtensionSystem::Get(browser_context())->extension_service();
443 extension_service->PromoteEphemeralApp(extension, false);
444 OnInstallSuccess(extension->id());
445 VLOG(1) << "Install success, sending response";
446 return RespondNow(NoArguments());
447 }
448
449 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). 431 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure().
450 AddRef(); 432 AddRef();
451 433
452 // The extension will install through the normal extension install flow, but 434 // The extension will install through the normal extension install flow, but
453 // the whitelist entry will bypass the normal permissions install dialog. 435 // the whitelist entry will bypass the normal permissions install dialog.
454 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 436 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
455 chrome_details_.GetProfile(), 437 chrome_details_.GetProfile(),
456 this, 438 this,
457 chrome_details_.GetAssociatedWebContents(), 439 chrome_details_.GetAssociatedWebContents(),
458 params->expected_id, 440 params->expected_id,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // The response is sent asynchronously in OnFetchComplete, OnInstallApproval, 519 // The response is sent asynchronously in OnFetchComplete, OnInstallApproval,
538 // or OnInstallComplete. 520 // or OnInstallComplete.
539 return RespondLater(); 521 return RespondLater();
540 } 522 }
541 523
542 void WebstorePrivateInstallBundleFunction::OnFetchComplete( 524 void WebstorePrivateInstallBundleFunction::OnFetchComplete(
543 const GURL& url, const SkBitmap* bitmap) { 525 const GURL& url, const SkBitmap* bitmap) {
544 BundleInstaller::ItemList items; 526 BundleInstaller::ItemList items;
545 for (const auto& entry : params_->contents) { 527 for (const auto& entry : params_->contents) {
546 // Skip already-installed items. 528 // Skip already-installed items.
547 if (util::IsExtensionInstalledPermanently(entry->id, browser_context()) || 529 bool is_installed =
530 extensions::ExtensionRegistry::Get(browser_context())->GetExtensionById(
531 entry->id, extensions::ExtensionRegistry::EVERYTHING) != nullptr;
532 if (is_installed ||
548 InstallTracker::Get(browser_context())->GetActiveInstall(entry->id)) { 533 InstallTracker::Get(browser_context())->GetActiveInstall(entry->id)) {
549 continue; 534 continue;
550 } 535 }
551 BundleInstaller::Item item; 536 BundleInstaller::Item item;
552 item.id = entry->id; 537 item.id = entry->id;
553 item.manifest = entry->manifest; 538 item.manifest = entry->manifest;
554 item.localized_name = entry->localized_name; 539 item.localized_name = entry->localized_name;
555 if (entry->icon_url) 540 if (entry->icon_url)
556 item.icon_url = source_url().Resolve(*entry->icon_url); 541 item.icon_url = source_url().Resolve(*entry->icon_url);
557 items.push_back(item); 542 items.push_back(item);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 WebstorePrivateGetEphemeralAppsEnabledFunction:: 702 WebstorePrivateGetEphemeralAppsEnabledFunction::
718 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} 703 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {}
719 704
720 ExtensionFunction::ResponseAction 705 ExtensionFunction::ResponseAction
721 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { 706 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() {
722 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( 707 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create(
723 false))); 708 false)));
724 } 709 }
725 710
726 } // namespace extensions 711 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698