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 072dd7b131fd323ee2a3e0a3b06a7a0af8e10b6b..01d09bd41729faf41aeac4fd82a793c9b443593f 100644 |
| --- a/chrome/browser/ui/webui/options/media_galleries_handler.cc |
| +++ b/chrome/browser/ui/webui/options/media_galleries_handler.cc |
| @@ -52,7 +52,10 @@ void MediaGalleriesHandler::InitializePage() { |
| if (pref_change_registrar_.IsEmpty()) { |
| pref_change_registrar_.Init(profile->GetPrefs()); |
| - pref_change_registrar_.Add(prefs::kMediaGalleriesRememberedGalleries, this); |
| + pref_change_registrar_.Add( |
| + prefs::kMediaGalleriesRememberedGalleries, |
| + base::Bind(&MediaGalleriesHandler::OnGalleriesChanged, |
| + base::Unretained(this))); |
| } |
| OnGalleriesChanged(); |
| @@ -69,30 +72,6 @@ void MediaGalleriesHandler::RegisterMessages() { |
| base::Unretained(this))); |
| } |
| -void MediaGalleriesHandler::OnGalleriesChanged() { |
| - Profile* profile = Profile::FromWebUI(web_ui()); |
| - chrome::MediaGalleriesPreferences* preferences = |
| - chrome::MediaFileSystemRegistry::GetInstance()->GetPreferences(profile); |
| - |
| - ListValue list; |
| - const MediaGalleriesPrefInfoMap& galleries = preferences->known_galleries(); |
| - for (MediaGalleriesPrefInfoMap::const_iterator iter = galleries.begin(); |
| - iter != galleries.end(); ++iter) { |
| - const MediaGalleryPrefInfo& gallery = iter->second; |
| - if (gallery.type == MediaGalleryPrefInfo::kBlackListed) |
| - continue; |
| - |
| - DictionaryValue* dict = new DictionaryValue(); |
| - dict->SetString("displayName", gallery.display_name); |
| - dict->SetString("path", gallery.AbsolutePath().LossyDisplayName()); |
| - dict->SetString("id", base::Uint64ToString(gallery.pref_id)); |
| - list.Append(dict); |
| - } |
| - |
| - web_ui()->CallJavascriptFunction( |
| - "options.MediaGalleriesManager.setAvailableMediaGalleries", list); |
| -} |
| - |
| void MediaGalleriesHandler::HandleAddNewGallery(const base::ListValue* args) { |
| ui::SelectFileDialog* dialog = ui::SelectFileDialog::Create( |
| this, |
| @@ -122,18 +101,37 @@ void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) { |
| prefs->ForgetGalleryById(id); |
| } |
| -void MediaGalleriesHandler::FileSelected( |
| - const FilePath& path, int index, void* params) { |
| +void MediaGalleriesHandler::FileSelected(const FilePath& path, |
| + int index, |
| + void* params) { |
| chrome::MediaGalleriesPreferences* prefs = |
| chrome::MediaFileSystemRegistry::GetInstance()->GetPreferences( |
| Profile::FromWebUI(web_ui())); |
| prefs->AddGalleryByPath(path); |
| } |
| -void MediaGalleriesHandler::OnPreferenceChanged(PrefServiceBase* service, |
| - const std::string& pref_name) { |
| - DCHECK_EQ(std::string(prefs::kMediaGalleriesRememberedGalleries), pref_name); |
| - OnGalleriesChanged(); |
| +void MediaGalleriesHandler::OnGalleriesChanged() { |
|
Jói
2012/11/21 13:37:45
You've reordered methods here, which is OK, but in
tfarina
2012/11/21 13:48:33
Done.
|
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + chrome::MediaGalleriesPreferences* preferences = |
| + chrome::MediaFileSystemRegistry::GetInstance()->GetPreferences(profile); |
| + |
| + ListValue list; |
| + const MediaGalleriesPrefInfoMap& galleries = preferences->known_galleries(); |
| + for (MediaGalleriesPrefInfoMap::const_iterator iter = galleries.begin(); |
| + iter != galleries.end(); ++iter) { |
| + const MediaGalleryPrefInfo& gallery = iter->second; |
| + if (gallery.type == MediaGalleryPrefInfo::kBlackListed) |
| + continue; |
| + |
| + DictionaryValue* dict = new DictionaryValue(); |
| + dict->SetString("displayName", gallery.display_name); |
| + dict->SetString("path", gallery.AbsolutePath().LossyDisplayName()); |
| + dict->SetString("id", base::Uint64ToString(gallery.pref_id)); |
| + list.Append(dict); |
| + } |
| + |
| + web_ui()->CallJavascriptFunction( |
| + "options.MediaGalleriesManager.setAvailableMediaGalleries", list); |
| } |
| } // namespace options |