Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc |
| index 099654c83ca061d0149bea2ee91172e878963664..c6bee15cff8750ade14f28968f26453d516fce5b 100644 |
| --- a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc |
| @@ -14,7 +14,10 @@ namespace chromeos { |
| namespace settings { |
| AndroidAppsHandler::AndroidAppsHandler(Profile* profile) |
| - : arc_prefs_observer_(this), profile_(profile), weak_ptr_factory_(this) {} |
| + : arc_prefs_observer_(this), |
| + arc_session_manager_observer_(this), |
| + profile_(profile), |
| + weak_ptr_factory_(this) {} |
| AndroidAppsHandler::~AndroidAppsHandler() {} |
| @@ -31,12 +34,16 @@ void AndroidAppsHandler::RegisterMessages() { |
| void AndroidAppsHandler::OnJavascriptAllowed() { |
| ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_); |
| - if (arc_prefs) |
| + if (arc_prefs) { |
| arc_prefs_observer_.Add(arc_prefs); |
| + // arc::ArcSessionManager is assosiated with primary profile. |
| + arc_session_manager_observer_.Add(arc::ArcSessionManager::Get()); |
| + } |
| } |
| void AndroidAppsHandler::OnJavascriptDisallowed() { |
| arc_prefs_observer_.RemoveAll(); |
| + arc_session_manager_observer_.RemoveAll(); |
| } |
| void AndroidAppsHandler::OnAppRegistered( |
| @@ -49,27 +56,24 @@ void AndroidAppsHandler::OnAppRemoved(const std::string& app_id) { |
| OnAppChanged(app_id); |
| } |
| -void AndroidAppsHandler::OnAppReadyChanged(const std::string& app_id, |
|
khmel
2017/05/10 00:35:13
ARC can run apps in deferred mode. We can ignore r
|
| - bool ready) { |
| - OnAppChanged(app_id); |
| -} |
| - |
| void AndroidAppsHandler::OnAppChanged(const std::string& app_id) { |
| if (app_id != arc::kSettingsAppId) |
| return; |
| SendAndroidAppsInfo(); |
| } |
| +void AndroidAppsHandler::OnArcPlayStoreEnabledChanged(bool enabled) { |
| + SendAndroidAppsInfo(); |
| +} |
| + |
| std::unique_ptr<base::DictionaryValue> |
| AndroidAppsHandler::BuildAndroidAppsInfo() { |
| std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue); |
| - bool app_ready = false; |
| - if (arc::IsArcPlayStoreEnabledForProfile(profile_)) { |
| - std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| - ArcAppListPrefs::Get(profile_)->GetApp(arc::kSettingsAppId); |
| - app_ready = app_info && app_info->ready; |
| - } |
| - info->SetBoolean("appReady", app_ready); |
| + info->SetBoolean("playStoreEnabled", |
| + arc::IsArcPlayStoreEnabledForProfile(profile_)); |
| + info->SetBoolean( |
| + "appSettingsAvailable", |
| + ArcAppListPrefs::Get(profile_)->IsRegistered(arc::kSettingsAppId)); |
| return info; |
| } |