Commit 7f81dfa0 authored by tmdiep@chromium.org's avatar tmdiep@chromium.org

Fixed cached ephemeral apps preventing install of the app via webstore private api

Fixed the following bug:
If an ephemeral app is cached, attempting to install via the app's
webstore detail page will fail. An error dialog will be displayed,
stating that the install is already in progress.

BUG=312460

Review URL: https://codereview.chromium.org/93943006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243234 0039d316-1c4b-4281-b951-d872f2087c98
parent 69c28833
......@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/gpu/gpu_feature_checker.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -299,9 +300,10 @@ bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl() {
ExtensionService* service =
extensions::ExtensionSystem::Get(GetProfile())->extension_service();
if (service->GetInstalledExtension(params_->details.id) ||
!g_pending_installs.Get().InsertInstall(GetProfile(),
params_->details.id)) {
if (extension_util::IsExtensionInstalledPermanently(params_->details.id,
service)
|| !g_pending_installs.Get().InsertInstall(GetProfile(),
params_->details.id)) {
SetResultCode(ALREADY_INSTALLED);
error_ = kAlreadyInstalledError;
return false;
......@@ -578,7 +580,7 @@ void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess(
if (test_webstore_installer_delegate)
test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
LOG(INFO) << "Install success, sending response";
VLOG(1) << "Install success, sending response";
g_pending_installs.Get().EraseInstall(GetProfile(), id);
SendResponse(true);
......@@ -598,7 +600,7 @@ void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure(
}
error_ = error;
LOG(INFO) << "Install failed, sending response";
VLOG(1) << "Install failed, sending response";
g_pending_installs.Get().EraseInstall(GetProfile(), id);
SendResponse(false);
......
......@@ -159,4 +159,11 @@ bool IsExtensionIdle(const std::string& extension_id,
return process_manager->GetRenderViewHostsForExtension(extension_id).empty();
}
bool IsExtensionInstalledPermanently(const std::string& extension_id,
const ExtensionService* service) {
DCHECK(service);
const Extension* extension = service->GetInstalledExtension(extension_id);
return extension && !extension->is_ephemeral();
}
} // namespace extension_util
......@@ -59,6 +59,10 @@ bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
bool IsExtensionIdle(const std::string& extension_id,
extensions::ExtensionSystem* extension_system);
// Whether an extension is installed permanently and not ephemerally.
bool IsExtensionInstalledPermanently(const std::string& extension_id,
const ExtensionService* service);
} // namespace extension_util
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_
......@@ -13,6 +13,7 @@
#include "chrome/browser/apps/ephemeral_app_launcher.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/install_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
......@@ -125,12 +126,9 @@ scoped_ptr<ChromeSearchResult> WebstoreResult::Duplicate() {
void WebstoreResult::UpdateActions() {
Actions actions;
const extensions::Extension* extension =
extensions::ExtensionSystem::Get(profile_)->extension_service()->
GetInstalledExtension(app_id_);
const bool is_otr = profile_->IsOffTheRecord();
const bool is_installed = extension && !extension->is_ephemeral();
const bool is_installed = extension_util::IsExtensionInstalledPermanently(
app_id_, extensions::ExtensionSystem::Get(profile_)->extension_service());
if (!is_otr && !is_installed && !is_installing()) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment