Chromium Code Reviews| Index: chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| index c7c8218560a6618a85f2ccb7e9790778e84889a1..0908705fc4aadfa5fd981d24887f6748aa0e4ae9 100644 |
| --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| @@ -686,6 +686,7 @@ void ArcAppListPrefs::OnInstanceReady() { |
| void ArcAppListPrefs::OnInstanceClosed() { |
| DisableAllApps(); |
| + installing_packages_.clear(); |
| binding_.Close(); |
| if (sync_service_) { |
| @@ -1127,24 +1128,35 @@ void ArcAppListPrefs::MaybeShowPackageInAppLauncher( |
| AppListService* service = AppListService::Get(); |
| CHECK(service); |
| service->ShowForAppInstall(profile_, app_id, false); |
| + last_shown_batch_installation_revision_ = |
| + current_batch_installation_revision_; |
| break; |
| } |
| } |
| +bool ArcAppListPrefs::IsNewPackageInSystem( |
| + const std::string& package_name) const { |
| + return !GetPackage(package_name) && |
| + !sync_service_->IsPackageSyncing(package_name); |
| +} |
| + |
| void ArcAppListPrefs::OnPackageAdded( |
| arc::mojom::ArcPackageInfoPtr package_info) { |
| DCHECK(IsArcEnabled()); |
| // Ignore packages installed by internal sync. |
| DCHECK(sync_service_); |
| - const bool new_package_in_system = !GetPackage(package_info->package_name) && |
| - !sync_service_->IsPackageSyncing(package_info->package_name); |
| + const bool new_package_in_system = IsNewPackageInSystem( |
| + package_info->package_name); |
| AddOrUpdatePackagePrefs(prefs_, *package_info); |
| for (auto& observer : observer_list_) |
| observer.OnPackageInstalled(*package_info); |
| - if (new_package_in_system) |
| + if (new_package_in_system && |
| + current_batch_installation_revision_ != |
| + last_shown_batch_installation_revision_) { |
| MaybeShowPackageInAppLauncher(*package_info); |
| + } |
| } |
| void ArcAppListPrefs::OnPackageModified( |
| @@ -1252,6 +1264,37 @@ void ArcAppListPrefs::OnIconInstalled(const std::string& app_id, |
| observer.OnAppIconUpdated(app_id, scale_factor); |
| } |
| +void ArcAppListPrefs::OnInstallationStarted(const std::string& name, |
| + const std::string& package_name) { |
| + if (IsNewPackageInSystem(package_name)) { |
| + // Check if we already have any installation in progress that is new in the |
| + // system. If no new pending packages are detected then consider this |
| + // installation as start of new batch installation group. |
| + bool has_new_pending_installation = false; |
| + for (const auto& pending_package_name : installing_packages_) { |
| + if (IsNewPackageInSystem(pending_package_name)) { |
| + has_new_pending_installation = true; |
| + break; |
| + } |
| + } |
| + if (!has_new_pending_installation) |
| + ++current_batch_installation_revision_; |
| + } |
| + installing_packages_.insert(package_name); |
|
xiyuan
2016/12/15 22:07:21
How important it is to check IsNewPackageInSystem
khmel
2016/12/16 00:35:30
I think we can change in this CL, thank you for id
|
| +} |
| + |
| +void ArcAppListPrefs::OnInstallationSetActive(const std::string& package_name) { |
| +} |
| + |
| +void ArcAppListPrefs::OnInstallationProgress(const std::string& package_name, |
| + float progress) { |
| +} |
| + |
| +void ArcAppListPrefs::OnInstallationFinished(const std::string& package_name, |
| + bool success) { |
| + installing_packages_.erase(package_name); |
| +} |
| + |
| ArcAppListPrefs::AppInfo::AppInfo(const std::string& name, |
| const std::string& package_name, |
| const std::string& activity, |