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 85% |
rename from chrome/browser/ui/app_list/drive/drive_app_converter.cc |
rename to chrome/browser/apps/drive/drive_app_converter.cc |
index 096a6f37cebfd151157eb6936374b86810ff86b8..77c395d53be5331437541976c350b5ce5f27d56c 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> |
@@ -26,6 +26,8 @@ |
using content::BrowserThread; |
+namespace extensions { |
+ |
// IconFetcher downloads |icon_url| using |converter|'s profile. The icon |
// url is passed from a DriveAppInfo and should follow icon url definition |
// in Drive API: |
@@ -115,8 +117,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 +149,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) { |
@@ -165,9 +172,17 @@ void DriveAppConverter::OnIconFetchComplete(const IconFetcher* fetcher) { |
void DriveAppConverter::StartInstall() { |
DCHECK(!crx_installer_); |
- crx_installer_ = extensions::CrxInstaller::CreateSilent( |
- extensions::ExtensionSystem::Get(profile_)->extension_service()); |
- extensions::InstallTracker::Get(profile_)->AddObserver(this); |
+ crx_installer_ = CrxInstaller::CreateSilent( |
+ ExtensionSystem::Get(profile_)->extension_service()); |
+ |
+ // Sets WAS_INSTALLED_BY_DEFAULT to make the converted url app not syncable. |
+ // Drive apps goes with the user's account and url apps will be created when |
benwells
2014/06/05 01:24:39
Nit: goes -> go
xiyuan
2014/06/05 17:48:32
Done.
|
+ // 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_creation_flags(Extension::FROM_BOOKMARK | |
+ Extension::WAS_INSTALLED_BY_DEFAULT); |
+ |
+ InstallTracker::Get(profile_)->AddObserver(this); |
crx_installer_->InstallWebApp(web_app_); |
} |
@@ -175,7 +190,7 @@ void DriveAppConverter::PostInstallCleanUp() { |
if (!crx_installer_) |
return; |
- extensions::InstallTracker::Get(profile_)->RemoveObserver(this); |
+ InstallTracker::Get(profile_)->RemoveObserver(this); |
crx_installer_ = NULL; |
} |
@@ -187,7 +202,10 @@ void DriveAppConverter::OnFinishCrxInstall(const std::string& extension_id, |
} |
app_ = crx_installer_->extension(); |
- finished_callback_.Run(this, success); |
- |
PostInstallCleanUp(); |
+ |
+ finished_callback_.Run(this, success); |
+ // |finished_callback_| could delete this. |
} |
+ |
+} // namespace extensions |