Handle window.localStorage === null case correctly.

Change-Id: I49ddf45093daee4988fb7f3b481fb35bfaceb152
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/521
Bug: 64525
(cherry picked from commit a56759d8fe5cfef7a06e115a2cb9d7e8bc403905)