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 7f0bb0b5f5b27ca823adf269de969ad77b63050d..00676ae8c6e46f2b0242f178d999625c921e7340 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 |
| @@ -607,10 +607,8 @@ void ArcAppListPrefs::SetLastLaunchTime(const std::string& app_id, |
| void ArcAppListPrefs::DisableAllApps() { |
| std::unordered_set<std::string> old_ready_apps; |
| old_ready_apps.swap(ready_apps_); |
| - for (auto& app_id : old_ready_apps) { |
| - for (auto& observer : observer_list_) |
| - observer.OnAppReadyChanged(app_id, false); |
| - } |
| + for (auto& app_id : old_ready_apps) |
| + NotifyAppReadyChanged(app_id, false); |
| } |
| void ArcAppListPrefs::NotifyRegisteredApps() { |
| @@ -644,8 +642,7 @@ void ArcAppListPrefs::RemoveAllApps() { |
| } else { |
| if (ready_apps_.count(app_id)) { |
| ready_apps_.erase(app_id); |
| - for (auto& observer : observer_list_) |
| - observer.OnAppReadyChanged(app_id, false); |
| + NotifyAppReadyChanged(app_id, false); |
| } |
| } |
| } |
| @@ -847,10 +844,8 @@ void ArcAppListPrefs::AddAppAndShortcut( |
| ready_apps_.insert(app_id); |
| if (was_tracked) { |
| - if (was_disabled && app_ready) { |
| - for (auto& observer : observer_list_) |
| - observer.OnAppReadyChanged(app_id, true); |
| - } |
| + if (was_disabled && app_ready) |
| + NotifyAppReadyChanged(app_id, true); |
| } else { |
| AppInfo app_info(updated_name, package_name, activity, intent_uri, |
| icon_resource_id, base::Time(), GetInstallTime(app_id), |
| @@ -984,7 +979,10 @@ void ArcAppListPrefs::OnAppListRefreshed( |
| if (IsShortcut(app_id)) { |
| // If this is a shortcut, we just mark it as ready. |
| - ready_apps_.insert(app_id); |
| + if (!ready_apps_.count(app_id)) { |
| + ready_apps_.insert(app_id); |
| + NotifyAppReadyChanged(app_id, true); |
|
khmel
2017/04/05 22:19:51
This is the actual reason of this bug. Ready state
|
| + } |
| } else { |
| // Default apps may not be installed yet at this moment. |
| if (!default_apps_.HasApp(app_id)) |
| @@ -1395,6 +1393,12 @@ void ArcAppListPrefs::OnInstallationFinished( |
| --installing_packages_count_; |
| } |
| +void ArcAppListPrefs::NotifyAppReadyChanged(const std::string& app_id, |
| + bool ready) { |
| + for (auto& observer : observer_list_) |
| + observer.OnAppReadyChanged(app_id, ready); |
| +} |
| + |
| ArcAppListPrefs::AppInfo::AppInfo(const std::string& name, |
| const std::string& package_name, |
| const std::string& activity, |