Chromium Code Reviews| Index: chrome/browser/ui/webui/options/media_galleries_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/media_galleries_handler.cc b/chrome/browser/ui/webui/options/media_galleries_handler.cc |
| index de76e34b104df31ee4274c9028fc6e1f518231ce..afba5cafca1ca57e07e4a9f8ea7672147d0dfe6d 100644 |
| --- a/chrome/browser/ui/webui/options/media_galleries_handler.cc |
| +++ b/chrome/browser/ui/webui/options/media_galleries_handler.cc |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/storage_monitor/storage_monitor.h" |
| #include "chrome/browser/ui/chrome_select_file_policy.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/pref_names.h" |
| @@ -26,7 +27,8 @@ using chrome::MediaGalleriesPreferences; |
| using chrome::MediaGalleriesPrefInfoMap; |
| using chrome::MediaGalleryPrefInfo; |
| -MediaGalleriesHandler::MediaGalleriesHandler() { |
| +MediaGalleriesHandler::MediaGalleriesHandler() |
| + : weak_ptr_factory_(this) { |
| } |
| MediaGalleriesHandler::~MediaGalleriesHandler() { |
| @@ -61,6 +63,10 @@ void MediaGalleriesHandler::InitializePage() { |
| base::Unretained(this))); |
| } |
| + // Note: this call will set up the StorageMonitor through a call to |
| + // GetPreferencesAsync. That is needed not only to populate the |
|
vandebo (ex-Chrome)
2013/05/23 15:04:17
comment out of date.
Greg Billock
2013/05/30 22:17:47
Done.
|
| + // initial page contents, but also to hook the preferences up to |
| + // device notifications so the change listener receives events. |
| OnGalleriesChanged(); |
| } |
| @@ -76,6 +82,12 @@ void MediaGalleriesHandler::RegisterMessages() { |
| } |
| void MediaGalleriesHandler::OnGalleriesChanged() { |
| + chrome::StorageMonitor::GetInstance()->Initialize( |
| + base::Bind(&MediaGalleriesHandler::OnStorageMonitorInitialized, |
| + weak_ptr_factory_.GetWeakPtr())); |
| +} |
| + |
| +void MediaGalleriesHandler::OnStorageMonitorInitialized() { |
| Profile* profile = Profile::FromWebUI(web_ui()); |
| chrome::MediaGalleriesPreferences* preferences = |
| g_browser_process->media_file_system_registry()->GetPreferences(profile); |
| @@ -123,19 +135,19 @@ void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) { |
| return; |
| } |
| - chrome::MediaGalleriesPreferences* prefs = |
| + chrome::MediaGalleriesPreferences* preferences = |
| g_browser_process->media_file_system_registry()->GetPreferences( |
| Profile::FromWebUI(web_ui())); |
| - prefs->ForgetGalleryById(id); |
| + preferences->ForgetGalleryById(id); |
| } |
| void MediaGalleriesHandler::FileSelected(const base::FilePath& path, |
| int index, |
| void* params) { |
| - chrome::MediaGalleriesPreferences* prefs = |
| + chrome::MediaGalleriesPreferences* preferences = |
| g_browser_process->media_file_system_registry()->GetPreferences( |
| Profile::FromWebUI(web_ui())); |
| - prefs->AddGalleryByPath(path); |
| + preferences->AddGalleryByPath(path); |
| } |
| } // namespace options |