| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options/media_galleries_handler.h" | 5 #include "chrome/browser/ui/webui/options/media_galleries_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 12 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 13 #include "chrome/browser/media_galleries/media_galleries_histograms.h" | 13 #include "chrome/browser/media_galleries/media_galleries_histograms.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 15 #include "chrome/browser/storage_monitor/storage_monitor.h" | 16 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 16 #include "chrome/browser/ui/chrome_select_file_policy.h" | 17 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_view.h" | 21 #include "content/public/browser/web_contents_view.h" |
| 21 #include "content/public/browser/web_ui.h" | 22 #include "content/public/browser/web_ui.h" |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 | 24 |
| 24 namespace options { | 25 namespace options { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 DCHECK(pref->IsInitialized()); | 87 DCHECK(pref->IsInitialized()); |
| 87 ListValue list; | 88 ListValue list; |
| 88 const MediaGalleriesPrefInfoMap& galleries = pref->known_galleries(); | 89 const MediaGalleriesPrefInfoMap& galleries = pref->known_galleries(); |
| 89 for (MediaGalleriesPrefInfoMap::const_iterator iter = galleries.begin(); | 90 for (MediaGalleriesPrefInfoMap::const_iterator iter = galleries.begin(); |
| 90 iter != galleries.end(); ++iter) { | 91 iter != galleries.end(); ++iter) { |
| 91 const MediaGalleryPrefInfo& gallery = iter->second; | 92 const MediaGalleryPrefInfo& gallery = iter->second; |
| 92 if (gallery.type == MediaGalleryPrefInfo::kBlackListed) | 93 if (gallery.type == MediaGalleryPrefInfo::kBlackListed) |
| 93 continue; | 94 continue; |
| 94 | 95 |
| 95 DictionaryValue* dict = new DictionaryValue(); | 96 DictionaryValue* dict = new DictionaryValue(); |
| 96 dict->SetString("displayName", gallery.GetGalleryDisplayName()); | 97 dict->SetString("displayName", |
| 98 MediaStorageUtil::GetGalleryDisplayNameFromPath( |
| 99 gallery.AbsolutePath())); |
| 97 dict->SetString("path", gallery.AbsolutePath().LossyDisplayName()); | 100 dict->SetString("path", gallery.AbsolutePath().LossyDisplayName()); |
| 98 dict->SetString("id", base::Uint64ToString(gallery.pref_id)); | 101 dict->SetString("id", base::Uint64ToString(gallery.pref_id)); |
| 99 list.Append(dict); | 102 list.Append(dict); |
| 100 } | 103 } |
| 101 | 104 |
| 102 web_ui()->CallJavascriptFunction( | 105 web_ui()->CallJavascriptFunction( |
| 103 "options.MediaGalleriesManager.setAvailableMediaGalleries", list); | 106 "options.MediaGalleriesManager.setAvailableMediaGalleries", list); |
| 104 } | 107 } |
| 105 | 108 |
| 106 void MediaGalleriesHandler::HandleAddNewGallery(const base::ListValue* args) { | 109 void MediaGalleriesHandler::HandleAddNewGallery(const base::ListValue* args) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 Profile* profile = Profile::FromWebUI(web_ui()); | 163 Profile* profile = Profile::FromWebUI(web_ui()); |
| 161 MediaGalleriesPreferences* preferences = | 164 MediaGalleriesPreferences* preferences = |
| 162 g_browser_process->media_file_system_registry()->GetPreferences(profile); | 165 g_browser_process->media_file_system_registry()->GetPreferences(profile); |
| 163 DCHECK(preferences->IsInitialized()); | 166 DCHECK(preferences->IsInitialized()); |
| 164 preferences->RemoveGalleryChangeObserver(this); | 167 preferences->RemoveGalleryChangeObserver(this); |
| 165 preferences->AddGalleryChangeObserver(this); | 168 preferences->AddGalleryChangeObserver(this); |
| 166 OnGalleriesChanged(preferences); | 169 OnGalleriesChanged(preferences); |
| 167 } | 170 } |
| 168 | 171 |
| 169 } // namespace options | 172 } // namespace options |
| OLD | NEW |