diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:14:28 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:14:28 +0000 |
commit | d557fa0599def3bb9c325fd8fb666a17bf8e6ea4 (patch) | |
tree | 59966b01c73a2bff998f6f462bb74ced4166f657 /chrome | |
parent | 2ba3b745c8b1177da38ff8b6bca854a402eb1648 (diff) | |
download | chromium_src-d557fa0599def3bb9c325fd8fb666a17bf8e6ea4.zip chromium_src-d557fa0599def3bb9c325fd8fb666a17bf8e6ea4.tar.gz chromium_src-d557fa0599def3bb9c325fd8fb666a17bf8e6ea4.tar.bz2 |
Rename media gallery -> media galleries in pref/UI components.
Also rename registry to preferences.
BUG=NONE
Review URL: https://chromiumcodereview.appspot.com/10835016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
20 files changed, 186 insertions, 183 deletions
diff --git a/chrome/browser/media_gallery/media_gallery_registry.cc b/chrome/browser/media_gallery/media_galleries_preferences.cc index c9d01da..600688e 100644 --- a/chrome/browser/media_gallery/media_gallery_registry.cc +++ b/chrome/browser/media_gallery/media_galleries_preferences.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/media_gallery/media_gallery_registry.h" +#include "chrome/browser/media_gallery/media_galleries_preferences.h" #include "base/command_line.h" #include "base/string_number_conversions.h" @@ -16,13 +16,13 @@ namespace { -const char kMediaGalleryIdKey[] = "id"; -const char kMediaGalleryPathKey[] = "path"; -const char kMediaGalleryDisplayNameKey[] = "displayName"; +const char kMediaGalleriesIdKey[] = "id"; +const char kMediaGalleriesPathKey[] = "path"; +const char kMediaGalleriesDisplayNameKey[] = "displayName"; bool GetId(const DictionaryValue* dict, uint64* value) { std::string string_id; - if (!dict->GetString(kMediaGalleryIdKey, &string_id) || + if (!dict->GetString(kMediaGalleriesIdKey, &string_id) || !base::StringToUint64(string_id, value)) { return false; } @@ -36,8 +36,8 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict, FilePath::StringType path; string16 display_name; if (!GetId(dict, &id) || - !dict->GetString(kMediaGalleryPathKey, &path) || - !dict->GetString(kMediaGalleryDisplayNameKey, &display_name)) { + !dict->GetString(kMediaGalleriesPathKey, &path) || + !dict->GetString(kMediaGalleriesDisplayNameKey, &display_name)) { return false; } @@ -49,10 +49,10 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict, DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) { DictionaryValue* dict = new DictionaryValue(); - dict->SetString(kMediaGalleryIdKey, base::Uint64ToString(gallery.id)); - dict->SetString(kMediaGalleryPathKey, gallery.path.value()); + dict->SetString(kMediaGalleriesIdKey, base::Uint64ToString(gallery.id)); + dict->SetString(kMediaGalleriesPathKey, gallery.path.value()); // TODO(estade): save |path| and |identifier|. - dict->SetString(kMediaGalleryDisplayNameKey, gallery.display_name); + dict->SetString(kMediaGalleriesDisplayNameKey, gallery.display_name); return dict; } @@ -61,20 +61,20 @@ DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) { MediaGallery::MediaGallery() : id(0) {} MediaGallery::~MediaGallery() {} -MediaGalleryRegistry::MediaGalleryRegistry(Profile* profile) +MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile) : profile_(profile) { DCHECK(UserInteractionIsEnabled()); InitFromPrefs(); } -MediaGalleryRegistry::~MediaGalleryRegistry() {} +MediaGalleriesPreferences::~MediaGalleriesPreferences() {} -void MediaGalleryRegistry::InitFromPrefs() { +void MediaGalleriesPreferences::InitFromPrefs() { remembered_galleries_.clear(); PrefService* prefs = profile_->GetPrefs(); const ListValue* list = prefs->GetList( - prefs::kMediaGalleryRememberedGalleries); + prefs::kMediaGalleriesRememberedGalleries); for (ListValue::const_iterator it = list->begin(); it != list->end(); it++) { const DictionaryValue* dict = NULL; @@ -87,27 +87,27 @@ void MediaGalleryRegistry::InitFromPrefs() { } } -void MediaGalleryRegistry::AddGalleryByPath(const FilePath& path) { +void MediaGalleriesPreferences::AddGalleryByPath(const FilePath& path) { PrefService* prefs = profile_->GetPrefs(); MediaGallery gallery; - gallery.id = prefs->GetUint64(prefs::kMediaGalleryUniqueId); - prefs->SetUint64(prefs::kMediaGalleryUniqueId, gallery.id + 1); + gallery.id = prefs->GetUint64(prefs::kMediaGalleriesUniqueId); + prefs->SetUint64(prefs::kMediaGalleriesUniqueId, gallery.id + 1); gallery.display_name = path.BaseName().LossyDisplayName(); // TODO(estade): make this relative to base_path. gallery.path = path; // TODO(estade): populate the rest of the fields. - ListPrefUpdate update(prefs, prefs::kMediaGalleryRememberedGalleries); + ListPrefUpdate update(prefs, prefs::kMediaGalleriesRememberedGalleries); ListValue* list = update.Get(); list->Append(CreateGalleryDictionary(gallery)); remembered_galleries_.push_back(gallery); } -void MediaGalleryRegistry::ForgetGalleryById(uint64 id) { +void MediaGalleriesPreferences::ForgetGalleryById(uint64 id) { PrefService* prefs = profile_->GetPrefs(); - ListPrefUpdate update(prefs, prefs::kMediaGalleryRememberedGalleries); + ListPrefUpdate update(prefs, prefs::kMediaGalleriesRememberedGalleries); ListValue* list = update.Get(); for (ListValue::iterator iter = list->begin(); iter != list->end(); ++iter) { @@ -122,23 +122,23 @@ void MediaGalleryRegistry::ForgetGalleryById(uint64 id) { } } -void MediaGalleryRegistry::Shutdown() { +void MediaGalleriesPreferences::Shutdown() { profile_ = NULL; } // static -bool MediaGalleryRegistry::UserInteractionIsEnabled() { +bool MediaGalleriesPreferences::UserInteractionIsEnabled() { return CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableMediaGalleryUI); } // static -void MediaGalleryRegistry::RegisterUserPrefs(PrefService* prefs) { +void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) { if (!UserInteractionIsEnabled()) return; - prefs->RegisterListPref(prefs::kMediaGalleryRememberedGalleries, + prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries, PrefService::UNSYNCABLE_PREF); - prefs->RegisterUint64Pref(prefs::kMediaGalleryUniqueId, 0, + prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, 0, PrefService::UNSYNCABLE_PREF); } diff --git a/chrome/browser/media_gallery/media_gallery_registry.h b/chrome/browser/media_gallery/media_galleries_preferences.h index f6bebe5..495501f 100644 --- a/chrome/browser/media_gallery/media_gallery_registry.h +++ b/chrome/browser/media_gallery/media_galleries_preferences.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_H_ -#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_H_ +#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ +#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ #include <list> #include <string> @@ -44,10 +44,12 @@ struct MediaGallery { // A class to manage the media galleries that the user has added, explicitly or // otherwise. There is one registry per user profile. // TODO(estade): should MediaFileSystemRegistry be merged into this class? -class MediaGalleryRegistry : public ProfileKeyedService { +class MediaGalleriesPreferences : public ProfileKeyedService { public: - explicit MediaGalleryRegistry(Profile* profile); - virtual ~MediaGalleryRegistry(); + typedef std::list<MediaGallery> MediaGalleries; + + explicit MediaGalleriesPreferences(Profile* profile); + virtual ~MediaGalleriesPreferences(); // Builds |remembered_galleries_| from the persistent store. void InitFromPrefs(); @@ -59,8 +61,6 @@ class MediaGalleryRegistry : public ProfileKeyedService { // Removes the gallery identified by |id| from the store. void ForgetGalleryById(uint64 id); - typedef std::list<MediaGallery> MediaGalleries; - const MediaGalleries& remembered_galleries() const { return remembered_galleries_; } @@ -81,7 +81,7 @@ class MediaGalleryRegistry : public ProfileKeyedService { // TODO(estade): either actually use this, or remove it. MediaGalleries remembered_galleries_; - DISALLOW_COPY_AND_ASSIGN(MediaGalleryRegistry); + DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferences); }; -#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_H_ +#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_ diff --git a/chrome/browser/media_gallery/media_galleries_preferences_factory.cc b/chrome/browser/media_gallery/media_galleries_preferences_factory.cc new file mode 100644 index 0000000..7cda9d8f --- /dev/null +++ b/chrome/browser/media_gallery/media_galleries_preferences_factory.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" + +#include "chrome/browser/media_gallery/media_galleries_preferences.h" +#include "chrome/browser/profiles/profile_dependency_manager.h" + +// static +MediaGalleriesPreferences* MediaGalleriesPreferencesFactory::GetForProfile( + Profile* profile) { + return static_cast<MediaGalleriesPreferences*>( + GetInstance()->GetServiceForProfile(profile, true)); +} + +// static +MediaGalleriesPreferencesFactory* +MediaGalleriesPreferencesFactory::GetInstance() { + return Singleton<MediaGalleriesPreferencesFactory>::get(); +} + +MediaGalleriesPreferencesFactory::MediaGalleriesPreferencesFactory() + : ProfileKeyedServiceFactory("MediaGalleriesPreferences", + ProfileDependencyManager::GetInstance()) {} + +MediaGalleriesPreferencesFactory::~MediaGalleriesPreferencesFactory() {} + +ProfileKeyedService* MediaGalleriesPreferencesFactory::BuildServiceInstanceFor( + Profile* profile) const { + return new MediaGalleriesPreferences(profile); +} + +void MediaGalleriesPreferencesFactory::RegisterUserPrefs(PrefService* prefs) { + MediaGalleriesPreferences::RegisterUserPrefs(prefs); +} + +bool MediaGalleriesPreferencesFactory::ServiceRedirectedInIncognito() { + return true; +} diff --git a/chrome/browser/media_gallery/media_galleries_preferences_factory.h b/chrome/browser/media_gallery/media_galleries_preferences_factory.h new file mode 100644 index 0000000..c972886 --- /dev/null +++ b/chrome/browser/media_gallery/media_galleries_preferences_factory.h @@ -0,0 +1,38 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_ +#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_ + +#include "base/basictypes.h" +#include "base/memory/singleton.h" +#include "chrome/browser/profiles/profile_keyed_service_factory.h" + +class Profile; +class MediaGalleriesPreferences; + +// Singleton that owns all MediaGalleriesPreferences and associates them with +// Profiles. +class MediaGalleriesPreferencesFactory : public ProfileKeyedServiceFactory { + public: + static MediaGalleriesPreferences* GetForProfile(Profile* profile); + + static MediaGalleriesPreferencesFactory* GetInstance(); + + private: + friend struct DefaultSingletonTraits<MediaGalleriesPreferencesFactory>; + + MediaGalleriesPreferencesFactory(); + virtual ~MediaGalleriesPreferencesFactory(); + + // ProfileKeyedServiceFactory: + virtual ProfileKeyedService* BuildServiceInstanceFor( + Profile* profile) const OVERRIDE; + virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; + virtual bool ServiceRedirectedInIncognito() OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferencesFactory); +}; + +#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_ diff --git a/chrome/browser/media_gallery/media_gallery_registry_factory.cc b/chrome/browser/media_gallery/media_gallery_registry_factory.cc deleted file mode 100644 index abd3f1e..0000000 --- a/chrome/browser/media_gallery/media_gallery_registry_factory.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/media_gallery/media_gallery_registry_factory.h" - -#include "chrome/browser/media_gallery/media_gallery_registry.h" -#include "chrome/browser/profiles/profile_dependency_manager.h" - -// static -MediaGalleryRegistry* MediaGalleryRegistryFactory::GetForProfile( - Profile* profile) { - return static_cast<MediaGalleryRegistry*>( - GetInstance()->GetServiceForProfile(profile, true)); -} - -// static -MediaGalleryRegistryFactory* MediaGalleryRegistryFactory::GetInstance() { - return Singleton<MediaGalleryRegistryFactory>::get(); -} - -MediaGalleryRegistryFactory::MediaGalleryRegistryFactory() - : ProfileKeyedServiceFactory("MediaGalleryRegistry", - ProfileDependencyManager::GetInstance()) {} - -MediaGalleryRegistryFactory::~MediaGalleryRegistryFactory() {} - -ProfileKeyedService* MediaGalleryRegistryFactory::BuildServiceInstanceFor( - Profile* profile) const { - return new MediaGalleryRegistry(profile); -} - -void MediaGalleryRegistryFactory::RegisterUserPrefs(PrefService* prefs) { - MediaGalleryRegistry::RegisterUserPrefs(prefs); -} - -bool MediaGalleryRegistryFactory::ServiceRedirectedInIncognito() { - return true; -} diff --git a/chrome/browser/media_gallery/media_gallery_registry_factory.h b/chrome/browser/media_gallery/media_gallery_registry_factory.h deleted file mode 100644 index c6d9d26..0000000 --- a/chrome/browser/media_gallery/media_gallery_registry_factory.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ -#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ - -#include "base/basictypes.h" -#include "base/memory/singleton.h" -#include "chrome/browser/profiles/profile_keyed_service_factory.h" - -class Profile; -class MediaGalleryRegistry; - -// Singleton that owns all MediaGalleryRegistries and associates them with -// Profiles. -class MediaGalleryRegistryFactory : public ProfileKeyedServiceFactory { - public: - static MediaGalleryRegistry* GetForProfile(Profile* profile); - - static MediaGalleryRegistryFactory* GetInstance(); - - private: - friend struct DefaultSingletonTraits<MediaGalleryRegistryFactory>; - - MediaGalleryRegistryFactory(); - virtual ~MediaGalleryRegistryFactory(); - - // ProfileKeyedServiceFactory: - virtual ProfileKeyedService* BuildServiceInstanceFor( - Profile* profile) const OVERRIDE; - virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; - virtual bool ServiceRedirectedInIncognito() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(MediaGalleryRegistryFactory); -}; - -#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc index da41d67..c070b97 100644 --- a/chrome/browser/profiles/profile_dependency_manager.cc +++ b/chrome/browser/profiles/profile_dependency_manager.cc @@ -22,7 +22,7 @@ #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/shortcuts_backend_factory.h" #include "chrome/browser/intents/web_intents_registry_factory.h" -#include "chrome/browser/media_gallery/media_gallery_registry_factory.h" +#include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/plugin_prefs_factory.h" @@ -225,7 +225,7 @@ void ProfileDependencyManager::AssertFactoriesBuilt() { #if defined(ENABLE_CONFIGURATION_POLICY) ManagedModePolicyProviderFactory::GetInstance(); #endif - MediaGalleryRegistryFactory::GetInstance(); + MediaGalleriesPreferencesFactory::GetInstance(); NTPResourceCacheFactory::GetInstance(); PasswordStoreFactory::GetInstance(); PersonalDataManagerFactory::GetInstance(); diff --git a/chrome/browser/resources/options2/content_settings.html b/chrome/browser/resources/options2/content_settings.html index 6cf618b..54c5004 100644 --- a/chrome/browser/resources/options2/content_settings.html +++ b/chrome/browser/resources/options2/content_settings.html @@ -318,7 +318,7 @@ i18n-content="manage_exceptions"></button> </div> </section> - <section id="media-gallery-section" hidden> + <section id="media-galleries-section" hidden> <h3 i18n-content="mediaGalleriesSectionLabel"></h3> <div> <button id="manage-galleries-button" diff --git a/chrome/browser/resources/options2/media_gallery_list.js b/chrome/browser/resources/options2/media_galleries_list.js index 5f85755..417084b 100644 --- a/chrome/browser/resources/options2/media_gallery_list.js +++ b/chrome/browser/resources/options2/media_galleries_list.js @@ -10,15 +10,15 @@ cr.define('options', function() { * @constructor * @extends {DeletableItem} */ - function MediaGalleryListItem(galleryInfo) { + function MediaGalleriesListItem(galleryInfo) { var el = cr.doc.createElement('div'); el.galleryInfo_ = galleryInfo; - el.__proto__ = MediaGalleryListItem.prototype; + el.__proto__ = MediaGalleriesListItem.prototype; el.decorate(); return el; } - MediaGalleryListItem.prototype = { + MediaGalleriesListItem.prototype = { __proto__: DeletableItem.prototype, decorate: function() { @@ -31,9 +31,9 @@ cr.define('options', function() { }, }; - var MediaGalleryList = cr.ui.define('list'); + var MediaGalleriesList = cr.ui.define('list'); - MediaGalleryList.prototype = { + MediaGalleriesList.prototype = { __proto__: DeletableItemList.prototype, /** @inheritDoc */ @@ -44,7 +44,7 @@ cr.define('options', function() { /** @inheritDoc */ createItem: function(galleryInfo) { - return new MediaGalleryListItem(galleryInfo); + return new MediaGalleriesListItem(galleryInfo); }, /** @inheritDoc */ @@ -54,6 +54,6 @@ cr.define('options', function() { }; return { - MediaGalleryList: MediaGalleryList + MediaGalleriesList: MediaGalleriesList }; }); diff --git a/chrome/browser/resources/options2/media_gallery_manager_overlay.html b/chrome/browser/resources/options2/media_galleries_manager_overlay.html index 5f4e10d..5f4e10d 100644 --- a/chrome/browser/resources/options2/media_gallery_manager_overlay.html +++ b/chrome/browser/resources/options2/media_galleries_manager_overlay.html diff --git a/chrome/browser/resources/options2/media_gallery_manager_overlay.js b/chrome/browser/resources/options2/media_galleries_manager_overlay.js index b5fb90f..e1a24ff 100644 --- a/chrome/browser/resources/options2/media_gallery_manager_overlay.js +++ b/chrome/browser/resources/options2/media_galleries_manager_overlay.js @@ -12,15 +12,15 @@ cr.define('options', function() { * @constructor * @extends {OptionsPage} */ - function MediaGalleryManager() { + function MediaGalleriesManager() { OptionsPage.call(this, 'manageGalleries', loadTimeData.getString('manageMediaGalleriesTabTitle'), 'manage-media-galleries-overlay'); } - cr.addSingletonGetter(MediaGalleryManager); + cr.addSingletonGetter(MediaGalleriesManager); - MediaGalleryManager.prototype = { + MediaGalleriesManager.prototype = { __proto__: OptionsPage.prototype, /** @@ -30,7 +30,7 @@ cr.define('options', function() { OptionsPage.prototype.initializePage.call(this); this.availableGalleriesList_ = $('available-galleries-list'); - options.MediaGalleryList.decorate(this.availableGalleriesList_); + options.MediaGalleriesList.decorate(this.availableGalleriesList_); $('new-media-gallery').addEventListener('click', function() { chrome.send('addNewGallery'); @@ -61,7 +61,7 @@ cr.define('options', function() { setAvailableMediaGalleries_: function(galleries) { $('available-galleries-list').dataModel = new ArrayDataModel(galleries); // TODO(estade): show this section by default. - $('media-gallery-section').hidden = false; + $('media-galleries-section').hidden = false; }, }, @@ -69,14 +69,14 @@ cr.define('options', function() { [ 'setAvailableMediaGalleries', ].forEach(function(name) { - MediaGalleryManager[name] = function() { - var instance = MediaGalleryManager.getInstance(); + MediaGalleriesManager[name] = function() { + var instance = MediaGalleriesManager.getInstance(); return instance[name + '_'].apply(instance, arguments); }; }); // Export return { - MediaGalleryManager: MediaGalleryManager + MediaGalleriesManager: MediaGalleriesManager }; }); diff --git a/chrome/browser/resources/options2/options.html b/chrome/browser/resources/options2/options.html index 0ef3aa6..c5bcac0 100644 --- a/chrome/browser/resources/options2/options.html +++ b/chrome/browser/resources/options2/options.html @@ -117,7 +117,7 @@ <include src="cookies_view_app.html"> <include src="handler_options.html"> <include src="language_add_language_overlay.html"> - <include src="media_gallery_manager_overlay.html"> + <include src="media_galleries_manager_overlay.html"> <if expr="pp_ifdef('chromeos')"> <include src="chromeos/internet_detail.html"> <include src="chromeos/preferred_networks.html"> diff --git a/chrome/browser/resources/options2/options.js b/chrome/browser/resources/options2/options.js index f47390f..487c517 100644 --- a/chrome/browser/resources/options2/options.js +++ b/chrome/browser/resources/options2/options.js @@ -20,7 +20,7 @@ var HomePageOverlay = options.HomePageOverlay; var ImportDataOverlay = options.ImportDataOverlay; var InstantConfirmOverlay = options.InstantConfirmOverlay; var LanguageOptions = options.LanguageOptions; -var MediaGalleryManager = options.MediaGalleryManager; +var MediaGalleriesManager = options.MediaGalleriesManager; var OptionsFocusManager = options.OptionsFocusManager; var OptionsPage = options.OptionsPage; var PasswordManager = options.PasswordManager; @@ -104,7 +104,7 @@ function load() { [$('language-button')]); OptionsPage.registerOverlay(ManageProfileOverlay.getInstance(), BrowserOptions.getInstance()); - OptionsPage.registerOverlay(MediaGalleryManager.getInstance(), + OptionsPage.registerOverlay(MediaGalleriesManager.getInstance(), ContentSettings.getInstance(), [$('manage-galleries-button')]); OptionsPage.registerOverlay(PasswordManager.getInstance(), diff --git a/chrome/browser/resources/options2/options_bundle.js b/chrome/browser/resources/options2/options_bundle.js index f3abbf0..6815119 100644 --- a/chrome/browser/resources/options2/options_bundle.js +++ b/chrome/browser/resources/options2/options_bundle.js @@ -83,8 +83,8 @@ <include src="language_list.js"></include> <include src="language_options.js"></include> <include src="manage_profile_overlay.js"></include> -<include src="media_gallery_list.js"></include> -<include src="media_gallery_manager_overlay.js"></include> +<include src="media_galleries_list.js"></include> +<include src="media_galleries_manager_overlay.js"></include> <include src="options_focus_manager.js"></include> <include src="password_manager.js"></include> <include src="password_manager_list.js"></include> diff --git a/chrome/browser/ui/webui/options2/media_gallery_handler.cc b/chrome/browser/ui/webui/options2/media_galleries_handler.cc index f0909dd..9453b0d 100644 --- a/chrome/browser/ui/webui/options2/media_gallery_handler.cc +++ b/chrome/browser/ui/webui/options2/media_galleries_handler.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/options2/media_gallery_handler.h" +#include "chrome/browser/ui/webui/options2/media_galleries_handler.h" #include "base/bind.h" -#include "chrome/browser/media_gallery/media_gallery_registry.h" -#include "chrome/browser/media_gallery/media_gallery_registry_factory.h" +#include "chrome/browser/media_gallery/media_galleries_preferences.h" +#include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/chrome_select_file_policy.h" @@ -20,13 +20,13 @@ namespace options2 { -MediaGalleryHandler::MediaGalleryHandler() { +MediaGalleriesHandler::MediaGalleriesHandler() { } -MediaGalleryHandler::~MediaGalleryHandler() { +MediaGalleriesHandler::~MediaGalleriesHandler() { } -void MediaGalleryHandler::GetLocalizedValues(DictionaryValue* values) { +void MediaGalleriesHandler::GetLocalizedValues(DictionaryValue* values) { DCHECK(values); static OptionsStringResource resources[] = { @@ -40,42 +40,42 @@ void MediaGalleryHandler::GetLocalizedValues(DictionaryValue* values) { IDS_MEDIA_GALLERY_MANAGE_TITLE); } -void MediaGalleryHandler::InitializeHandler() { - if (!MediaGalleryRegistry::UserInteractionIsEnabled()) +void MediaGalleriesHandler::InitializeHandler() { + if (!MediaGalleriesPreferences::UserInteractionIsEnabled()) return; Profile* profile = Profile::FromWebUI(web_ui()); pref_change_registrar_.Init(profile->GetPrefs()); - pref_change_registrar_.Add(prefs::kMediaGalleryRememberedGalleries, this); + pref_change_registrar_.Add(prefs::kMediaGalleriesRememberedGalleries, this); } -void MediaGalleryHandler::InitializePage() { - if (!MediaGalleryRegistry::UserInteractionIsEnabled()) +void MediaGalleriesHandler::InitializePage() { + if (!MediaGalleriesPreferences::UserInteractionIsEnabled()) return; OnGalleriesChanged(); } -void MediaGalleryHandler::RegisterMessages() { +void MediaGalleriesHandler::RegisterMessages() { web_ui()->RegisterMessageCallback( "addNewGallery", - base::Bind(&MediaGalleryHandler::HandleAddNewGallery, + base::Bind(&MediaGalleriesHandler::HandleAddNewGallery, base::Unretained(this))); web_ui()->RegisterMessageCallback( "forgetGallery", - base::Bind(&MediaGalleryHandler::HandleForgetGallery, + base::Bind(&MediaGalleriesHandler::HandleForgetGallery, base::Unretained(this))); } -void MediaGalleryHandler::OnGalleriesChanged() { +void MediaGalleriesHandler::OnGalleriesChanged() { Profile* profile = Profile::FromWebUI(web_ui()); const ListValue* list = profile->GetPrefs()->GetList( - prefs::kMediaGalleryRememberedGalleries); + prefs::kMediaGalleriesRememberedGalleries); web_ui()->CallJavascriptFunction( - "options.MediaGalleryManager.setAvailableMediaGalleries", *list); + "options.MediaGalleriesManager.setAvailableMediaGalleries", *list); } -void MediaGalleryHandler::HandleAddNewGallery(const base::ListValue* args) { +void MediaGalleriesHandler::HandleAddNewGallery(const base::ListValue* args) { SelectFileDialog* dialog = SelectFileDialog::Create( this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); @@ -89,29 +89,31 @@ void MediaGalleryHandler::HandleAddNewGallery(const base::ListValue* args) { NULL); } -void MediaGalleryHandler::HandleForgetGallery(const base::ListValue* args) { +void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) { // TODO(estade): use uint64. int id; CHECK(ExtractIntegerValue(args, &id)); - MediaGalleryRegistry* registry = - MediaGalleryRegistryFactory::GetForProfile(Profile::FromWebUI(web_ui())); - registry->ForgetGalleryById(id); + MediaGalleriesPreferences* prefs = + MediaGalleriesPreferencesFactory::GetForProfile( + Profile::FromWebUI(web_ui())); + prefs->ForgetGalleryById(id); } -void MediaGalleryHandler::FileSelected( +void MediaGalleriesHandler::FileSelected( const FilePath& path, int index, void* params) { - MediaGalleryRegistry* registry = - MediaGalleryRegistryFactory::GetForProfile(Profile::FromWebUI(web_ui())); - registry->AddGalleryByPath(path); + MediaGalleriesPreferences* prefs = + MediaGalleriesPreferencesFactory::GetForProfile( + Profile::FromWebUI(web_ui())); + prefs->AddGalleryByPath(path); } -void MediaGalleryHandler::Observe( +void MediaGalleriesHandler::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { if (type == chrome::NOTIFICATION_PREF_CHANGED && *content::Details<std::string>(details).ptr() == - prefs::kMediaGalleryRememberedGalleries) { + prefs::kMediaGalleriesRememberedGalleries) { OnGalleriesChanged(); } else { NOTREACHED(); diff --git a/chrome/browser/ui/webui/options2/media_gallery_handler.h b/chrome/browser/ui/webui/options2/media_galleries_handler.h index 37f24bb..f33162d 100644 --- a/chrome/browser/ui/webui/options2/media_gallery_handler.h +++ b/chrome/browser/ui/webui/options2/media_galleries_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERY_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERY_HANDLER_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERIES_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERIES_HANDLER_H_ #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/ui/select_file_dialog.h" @@ -13,11 +13,11 @@ namespace options2 { // Handles messages related to adding or removing media galleries. -class MediaGalleryHandler : public OptionsPageUIHandler, - public SelectFileDialog::Listener { +class MediaGalleriesHandler : public OptionsPageUIHandler, + public SelectFileDialog::Listener { public: - MediaGalleryHandler(); - virtual ~MediaGalleryHandler(); + MediaGalleriesHandler(); + virtual ~MediaGalleriesHandler(); // OptionsPageUIHandler implementation. virtual void GetLocalizedValues(base::DictionaryValue* values) OVERRIDE; @@ -46,9 +46,9 @@ class MediaGalleryHandler : public OptionsPageUIHandler, PrefChangeRegistrar pref_change_registrar_; - DISALLOW_COPY_AND_ASSIGN(MediaGalleryHandler); + DISALLOW_COPY_AND_ASSIGN(MediaGalleriesHandler); }; } // namespace options2 -#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERY_HANDLER_H_ +#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERIES_HANDLER_H_ diff --git a/chrome/browser/ui/webui/options2/options_ui.cc b/chrome/browser/ui/webui/options2/options_ui.cc index 1b4308b..a8f55ae 100644 --- a/chrome/browser/ui/webui/options2/options_ui.cc +++ b/chrome/browser/ui/webui/options2/options_ui.cc @@ -35,7 +35,7 @@ #include "chrome/browser/ui/webui/options2/import_data_handler.h" #include "chrome/browser/ui/webui/options2/language_options_handler.h" #include "chrome/browser/ui/webui/options2/manage_profile_handler.h" -#include "chrome/browser/ui/webui/options2/media_gallery_handler.h" +#include "chrome/browser/ui/webui/options2/media_galleries_handler.h" #include "chrome/browser/ui/webui/options2/options_sync_setup_handler.h" #include "chrome/browser/ui/webui/options2/password_manager_handler.h" #include "chrome/browser/ui/webui/options2/search_engine_manager_handler.h" @@ -235,7 +235,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler()); AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler()); AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler()); - AddOptionsPageUIHandler(localized_strings, new MediaGalleryHandler()); + AddOptionsPageUIHandler(localized_strings, new MediaGalleriesHandler()); AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler()); #if defined(OS_CHROMEOS) AddOptionsPageUIHandler(localized_strings, diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index c5c6033..0d7b26b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1412,14 +1412,14 @@ 'browser/media_gallery/media_device_notifications_window_win.h', 'browser/media_gallery/media_file_system_registry.cc', 'browser/media_gallery/media_file_system_registry.h', + 'browser/media_gallery/media_galleries_preferences.cc', + 'browser/media_gallery/media_galleries_preferences.h', + 'browser/media_gallery/media_galleries_preferences_factory.cc', + 'browser/media_gallery/media_galleries_preferences_factory.h', 'browser/media_gallery/media_gallery_database.cc', 'browser/media_gallery/media_gallery_database.h', 'browser/media_gallery/media_gallery_database_types.cc', 'browser/media_gallery/media_gallery_database_types.h', - 'browser/media_gallery/media_gallery_registry.cc', - 'browser/media_gallery/media_gallery_registry.h', - 'browser/media_gallery/media_gallery_registry_factory.cc', - 'browser/media_gallery/media_gallery_registry_factory.h', 'browser/memory_details.cc', 'browser/memory_details.h', 'browser/memory_details_android.cc', @@ -4147,8 +4147,8 @@ 'browser/ui/webui/options2/language_options_handler_common.h', 'browser/ui/webui/options2/manage_profile_handler.cc', 'browser/ui/webui/options2/manage_profile_handler.h', - 'browser/ui/webui/options2/media_gallery_handler.cc', - 'browser/ui/webui/options2/media_gallery_handler.h', + 'browser/ui/webui/options2/media_galleries_handler.cc', + 'browser/ui/webui/options2/media_galleries_handler.h', 'browser/ui/webui/options2/options_sync_setup_handler.cc', 'browser/ui/webui/options2/options_sync_setup_handler.h', 'browser/ui/webui/options2/options_ui.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 84ff5b9..a5f4ad9 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1941,12 +1941,12 @@ const char kComponentUpdaterState[] = "component_updater.state"; const char kWebIntentsEnabled[] = "webintents.enabled"; // The next media gallery ID to assign. -const char kMediaGalleryUniqueId[] = "media_gallery.gallery_id"; +const char kMediaGalleriesUniqueId[] = "media_galleries.gallery_id"; // A list of dictionaries, where each dictionary represents a known media // gallery. -const char kMediaGalleryRememberedGalleries[] = - "media_gallery.remembered_galleries"; +const char kMediaGalleriesRememberedGalleries[] = + "media_galleries.remembered_galleries"; #if defined(USE_AURA) // String value corresponding to ash::Shell::ShelfAlignment. diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 38bf02e..7e51d83 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -717,8 +717,8 @@ extern const char kComponentUpdaterState[]; extern const char kWebIntentsEnabled[]; -extern const char kMediaGalleryUniqueId[]; -extern const char kMediaGalleryRememberedGalleries[]; +extern const char kMediaGalleriesUniqueId[]; +extern const char kMediaGalleriesRememberedGalleries[]; #if defined(USE_AURA) extern const char kShelfAlignment[]; |