Make sure 'Android storage' link is always shown when ARC is running
This fixes a problem introduced in CL:1592713. Without this fix,
'storage-android-running-changed' is sent to JS only when either
of the following happens:
- AllowJavascript() is called.
- ARC is fully started.
- ARC shuts down.
However, storage-android-running-changed's listener on the JS side
is registered only after AllowJavascript() is called. Because of
this, if the Settings app is launched in the following way,
|androidRunning_| variable in storage.js remains false and the
'Android storage' link never shows up.
1. Sign in.
2. ARC is fully started.
3. Settings app is launched. |androidRunning_| variable is false
at this point.
4. AllowJavascript() is called.
5. 'storage-android-running-changed' is sent to JS, BUT there's
no listener.
6. The user moves to Devices > Storage management.
7. storage-android-running-changed's listener is registered.
8. The JS sends 'updateStorageInfo' to the C++ side, but the C++
handler doesn't fire storage-android-running-changed.
This CL changes the C++ handler code so that HandleUpdateStorageInfo()
fires storage-android-running-changed with the up to date ARC status.
The C++ handler used to do that, but CL:1592713 removed it by
mistake. This CL restores the code.
BUG=968580
(cherry picked from commit 7068b8ad93d561e3b9cd3d9620cf8066e99d571b)
Change-Id: If1d0a6d1597bffcb37b82c1e4c44746c4c201106
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637038
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: Michael Giuffrida <michaelpg@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#665170}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661115
Reviewed-by: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#319}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
index 90053ff..cf9b1c93 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
@@ -170,6 +170,7 @@
UpdateDownloadsSize();
UpdateDriveCacheSize();
UpdateBrowsingDataSize();
+ UpdateAndroidRunning();
UpdateAndroidSize();
UpdateCrostiniSize();
UpdateOtherUsersSize();
@@ -348,6 +349,11 @@
}
}
+void StorageHandler::UpdateAndroidRunning() {
+ FireWebUIListener("storage-android-running-changed",
+ base::Value(is_android_running_));
+}
+
void StorageHandler::UpdateAndroidSize() {
if (!is_android_running_)
return;
@@ -449,13 +455,13 @@
void StorageHandler::OnConnectionReady() {
is_android_running_ = true;
- FireWebUIListener("storage-android-running-changed", base::Value(true));
+ UpdateAndroidRunning();
UpdateAndroidSize();
}
void StorageHandler::OnConnectionClosed() {
is_android_running_ = false;
- FireWebUIListener("storage-android-running-changed", base::Value(false));
+ UpdateAndroidRunning();
}
void StorageHandler::OnArcPlayStoreEnabledChanged(bool enabled) {
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
index f35106f..cefa5753 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
@@ -103,6 +103,9 @@
// Callback to update the UI about the size of browsing data.
void OnGetBrowsingDataSize(bool is_site_data, int64_t size);
+ // Requests updating the flag that hides the Android size UI.
+ void UpdateAndroidRunning();
+
// Requests updating the space size used by Android apps and cache.
void UpdateAndroidSize();