Index: chrome/browser/apps/drive/drive_app_converter.cc |
diff --git a/chrome/browser/ui/app_list/drive/drive_app_converter.cc b/chrome/browser/apps/drive/drive_app_converter.cc |
similarity index 88% |
rename from chrome/browser/ui/app_list/drive/drive_app_converter.cc |
rename to chrome/browser/apps/drive/drive_app_converter.cc |
index 096a6f37cebfd151157eb6936374b86810ff86b8..b63e1c31126b89fa0ba34abf94ab50fc048d42ce 100644 |
--- a/chrome/browser/ui/app_list/drive/drive_app_converter.cc |
+++ b/chrome/browser/apps/drive/drive_app_converter.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/app_list/drive/drive_app_converter.h" |
+#include "chrome/browser/apps/drive/drive_app_converter.h" |
#include <algorithm> |
#include <set> |
@@ -106,6 +106,7 @@ DriveAppConverter::DriveAppConverter(Profile* profile, |
: profile_(profile), |
app_info_(app_info), |
app_(NULL), |
+ is_new_install_(false), |
finished_callback_(finished_callback) { |
DCHECK(profile_); |
} |
@@ -115,8 +116,9 @@ DriveAppConverter::~DriveAppConverter() { |
} |
void DriveAppConverter::Start() { |
- if (app_info_.app_name.empty() || |
- !app_info_.create_url.is_valid()) { |
+ DCHECK(!IsStarted()); |
+ |
+ if (app_info_.app_name.empty() || !app_info_.create_url.is_valid()) { |
finished_callback_.Run(this, false); |
return; |
} |
@@ -146,6 +148,10 @@ void DriveAppConverter::Start() { |
StartInstall(); |
} |
+bool DriveAppConverter::IsStarted() const { |
+ return !fetchers_.empty() || crx_installer_; |
+} |
+ |
void DriveAppConverter::OnIconFetchComplete(const IconFetcher* fetcher) { |
const SkBitmap& icon = fetcher->icon(); |
if (!icon.empty() && icon.width() != 0) { |
@@ -167,6 +173,13 @@ void DriveAppConverter::StartInstall() { |
DCHECK(!crx_installer_); |
crx_installer_ = extensions::CrxInstaller::CreateSilent( |
extensions::ExtensionSystem::Get(profile_)->extension_service()); |
+ crx_installer_->set_creation_flags(extensions::Extension::FROM_BOOKMARK); |
+ // The converted url app should not be syncable. Drive apps go with the user's |
+ // account and url apps will be created when needed. Syncing those apps could |
+ // hit an edge case where the synced url apps become orphans when the user has |
+ // corresponding chrome apps. |
+ crx_installer_->set_do_not_sync(true); |
+ |
extensions::InstallTracker::Get(profile_)->AddObserver(this); |
crx_installer_->InstallWebApp(web_app_); |
} |
@@ -187,7 +200,9 @@ void DriveAppConverter::OnFinishCrxInstall(const std::string& extension_id, |
} |
app_ = crx_installer_->extension(); |
- finished_callback_.Run(this, success); |
- |
+ is_new_install_ = success && crx_installer_->current_version().empty(); |
PostInstallCleanUp(); |
+ |
+ finished_callback_.Run(this, success); |
+ // |finished_callback_| could delete this. |
} |