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

Unified Diff: chrome/browser/apps/drive/drive_app_converter.cc

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make generated flag logic easier to read, fix a not-detecting-user-install-properly bug Created 6 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 side-by-side diff with in-line comments
Download patch
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 86%
rename from chrome/browser/ui/app_list/drive/drive_app_converter.cc
rename to chrome/browser/apps/drive/drive_app_converter.cc
index 096a6f37cebfd151157eb6936374b86810ff86b8..18aa40b7022848b7fee173ea6af45e596292f92d 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,15 @@ void DriveAppConverter::Start() {
StartInstall();
}
+bool DriveAppConverter::IsStarted() const {
+ return !fetchers_.empty() || crx_installer_;
+}
+
+bool DriveAppConverter::IsInstalling(const std::string& app_id) const {
+ return crx_installer_ && crx_installer_->extension() &&
+ crx_installer_->extension()->id() == app_id;
+}
+
void DriveAppConverter::OnIconFetchComplete(const IconFetcher* fetcher) {
const SkBitmap& icon = fetcher->icon();
if (!icon.empty() && icon.width() != 0) {
@@ -167,6 +178,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 +205,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.
}

Powered by Google App Engine
This is Rietveld 408576698