Commit d557fa05 authored by vandebo@chromium.org's avatar vandebo@chromium.org

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
parent 2ba3b745
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/command_line.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
namespace { namespace {
const char kMediaGalleryIdKey[] = "id"; const char kMediaGalleriesIdKey[] = "id";
const char kMediaGalleryPathKey[] = "path"; const char kMediaGalleriesPathKey[] = "path";
const char kMediaGalleryDisplayNameKey[] = "displayName"; const char kMediaGalleriesDisplayNameKey[] = "displayName";
bool GetId(const DictionaryValue* dict, uint64* value) { bool GetId(const DictionaryValue* dict, uint64* value) {
std::string string_id; std::string string_id;
if (!dict->GetString(kMediaGalleryIdKey, &string_id) || if (!dict->GetString(kMediaGalleriesIdKey, &string_id) ||
!base::StringToUint64(string_id, value)) { !base::StringToUint64(string_id, value)) {
return false; return false;
} }
...@@ -36,8 +36,8 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict, ...@@ -36,8 +36,8 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict,
FilePath::StringType path; FilePath::StringType path;
string16 display_name; string16 display_name;
if (!GetId(dict, &id) || if (!GetId(dict, &id) ||
!dict->GetString(kMediaGalleryPathKey, &path) || !dict->GetString(kMediaGalleriesPathKey, &path) ||
!dict->GetString(kMediaGalleryDisplayNameKey, &display_name)) { !dict->GetString(kMediaGalleriesDisplayNameKey, &display_name)) {
return false; return false;
} }
...@@ -49,10 +49,10 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict, ...@@ -49,10 +49,10 @@ bool PopulateGalleryFromDictionary(const DictionaryValue* dict,
DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) { DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) {
DictionaryValue* dict = new DictionaryValue(); DictionaryValue* dict = new DictionaryValue();
dict->SetString(kMediaGalleryIdKey, base::Uint64ToString(gallery.id)); dict->SetString(kMediaGalleriesIdKey, base::Uint64ToString(gallery.id));
dict->SetString(kMediaGalleryPathKey, gallery.path.value()); dict->SetString(kMediaGalleriesPathKey, gallery.path.value());
// TODO(estade): save |path| and |identifier|. // TODO(estade): save |path| and |identifier|.
dict->SetString(kMediaGalleryDisplayNameKey, gallery.display_name); dict->SetString(kMediaGalleriesDisplayNameKey, gallery.display_name);
return dict; return dict;
} }
...@@ -61,20 +61,20 @@ DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) { ...@@ -61,20 +61,20 @@ DictionaryValue* CreateGalleryDictionary(const MediaGallery& gallery) {
MediaGallery::MediaGallery() : id(0) {} MediaGallery::MediaGallery() : id(0) {}
MediaGallery::~MediaGallery() {} MediaGallery::~MediaGallery() {}
MediaGalleryRegistry::MediaGalleryRegistry(Profile* profile) MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile)
: profile_(profile) { : profile_(profile) {
DCHECK(UserInteractionIsEnabled()); DCHECK(UserInteractionIsEnabled());
InitFromPrefs(); InitFromPrefs();
} }
MediaGalleryRegistry::~MediaGalleryRegistry() {} MediaGalleriesPreferences::~MediaGalleriesPreferences() {}
void MediaGalleryRegistry::InitFromPrefs() { void MediaGalleriesPreferences::InitFromPrefs() {
remembered_galleries_.clear(); remembered_galleries_.clear();
PrefService* prefs = profile_->GetPrefs(); PrefService* prefs = profile_->GetPrefs();
const ListValue* list = prefs->GetList( const ListValue* list = prefs->GetList(
prefs::kMediaGalleryRememberedGalleries); prefs::kMediaGalleriesRememberedGalleries);
for (ListValue::const_iterator it = list->begin(); it != list->end(); it++) { for (ListValue::const_iterator it = list->begin(); it != list->end(); it++) {
const DictionaryValue* dict = NULL; const DictionaryValue* dict = NULL;
...@@ -87,27 +87,27 @@ void MediaGalleryRegistry::InitFromPrefs() { ...@@ -87,27 +87,27 @@ void MediaGalleryRegistry::InitFromPrefs() {
} }
} }
void MediaGalleryRegistry::AddGalleryByPath(const FilePath& path) { void MediaGalleriesPreferences::AddGalleryByPath(const FilePath& path) {
PrefService* prefs = profile_->GetPrefs(); PrefService* prefs = profile_->GetPrefs();
MediaGallery gallery; MediaGallery gallery;
gallery.id = prefs->GetUint64(prefs::kMediaGalleryUniqueId); gallery.id = prefs->GetUint64(prefs::kMediaGalleriesUniqueId);
prefs->SetUint64(prefs::kMediaGalleryUniqueId, gallery.id + 1); prefs->SetUint64(prefs::kMediaGalleriesUniqueId, gallery.id + 1);
gallery.display_name = path.BaseName().LossyDisplayName(); gallery.display_name = path.BaseName().LossyDisplayName();
// TODO(estade): make this relative to base_path. // TODO(estade): make this relative to base_path.
gallery.path = path; gallery.path = path;
// TODO(estade): populate the rest of the fields. // TODO(estade): populate the rest of the fields.
ListPrefUpdate update(prefs, prefs::kMediaGalleryRememberedGalleries); ListPrefUpdate update(prefs, prefs::kMediaGalleriesRememberedGalleries);
ListValue* list = update.Get(); ListValue* list = update.Get();
list->Append(CreateGalleryDictionary(gallery)); list->Append(CreateGalleryDictionary(gallery));
remembered_galleries_.push_back(gallery); remembered_galleries_.push_back(gallery);
} }
void MediaGalleryRegistry::ForgetGalleryById(uint64 id) { void MediaGalleriesPreferences::ForgetGalleryById(uint64 id) {
PrefService* prefs = profile_->GetPrefs(); PrefService* prefs = profile_->GetPrefs();
ListPrefUpdate update(prefs, prefs::kMediaGalleryRememberedGalleries); ListPrefUpdate update(prefs, prefs::kMediaGalleriesRememberedGalleries);
ListValue* list = update.Get(); ListValue* list = update.Get();
for (ListValue::iterator iter = list->begin(); iter != list->end(); ++iter) { for (ListValue::iterator iter = list->begin(); iter != list->end(); ++iter) {
...@@ -122,23 +122,23 @@ void MediaGalleryRegistry::ForgetGalleryById(uint64 id) { ...@@ -122,23 +122,23 @@ void MediaGalleryRegistry::ForgetGalleryById(uint64 id) {
} }
} }
void MediaGalleryRegistry::Shutdown() { void MediaGalleriesPreferences::Shutdown() {
profile_ = NULL; profile_ = NULL;
} }
// static // static
bool MediaGalleryRegistry::UserInteractionIsEnabled() { bool MediaGalleriesPreferences::UserInteractionIsEnabled() {
return CommandLine::ForCurrentProcess()->HasSwitch( return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMediaGalleryUI); switches::kEnableMediaGalleryUI);
} }
// static // static
void MediaGalleryRegistry::RegisterUserPrefs(PrefService* prefs) { void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) {
if (!UserInteractionIsEnabled()) if (!UserInteractionIsEnabled())
return; return;
prefs->RegisterListPref(prefs::kMediaGalleryRememberedGalleries, prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries,
PrefService::UNSYNCABLE_PREF); PrefService::UNSYNCABLE_PREF);
prefs->RegisterUint64Pref(prefs::kMediaGalleryUniqueId, 0, prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, 0,
PrefService::UNSYNCABLE_PREF); PrefService::UNSYNCABLE_PREF);
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_H_ #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_H_ #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_H_
#include <list> #include <list>
#include <string> #include <string>
...@@ -44,10 +44,12 @@ struct MediaGallery { ...@@ -44,10 +44,12 @@ struct MediaGallery {
// A class to manage the media galleries that the user has added, explicitly or // A class to manage the media galleries that the user has added, explicitly or
// otherwise. There is one registry per user profile. // otherwise. There is one registry per user profile.
// TODO(estade): should MediaFileSystemRegistry be merged into this class? // TODO(estade): should MediaFileSystemRegistry be merged into this class?
class MediaGalleryRegistry : public ProfileKeyedService { class MediaGalleriesPreferences : public ProfileKeyedService {
public: public:
explicit MediaGalleryRegistry(Profile* profile); typedef std::list<MediaGallery> MediaGalleries;
virtual ~MediaGalleryRegistry();
explicit MediaGalleriesPreferences(Profile* profile);
virtual ~MediaGalleriesPreferences();
// Builds |remembered_galleries_| from the persistent store. // Builds |remembered_galleries_| from the persistent store.
void InitFromPrefs(); void InitFromPrefs();
...@@ -59,8 +61,6 @@ class MediaGalleryRegistry : public ProfileKeyedService { ...@@ -59,8 +61,6 @@ class MediaGalleryRegistry : public ProfileKeyedService {
// Removes the gallery identified by |id| from the store. // Removes the gallery identified by |id| from the store.
void ForgetGalleryById(uint64 id); void ForgetGalleryById(uint64 id);
typedef std::list<MediaGallery> MediaGalleries;
const MediaGalleries& remembered_galleries() const { const MediaGalleries& remembered_galleries() const {
return remembered_galleries_; return remembered_galleries_;
} }
...@@ -81,7 +81,7 @@ class MediaGalleryRegistry : public ProfileKeyedService { ...@@ -81,7 +81,7 @@ class MediaGalleryRegistry : public ProfileKeyedService {
// TODO(estade): either actually use this, or remove it. // TODO(estade): either actually use this, or remove it.
MediaGalleries remembered_galleries_; 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_
...@@ -2,38 +2,39 @@ ...@@ -2,38 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/media_gallery/media_gallery_registry_factory.h" #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h"
#include "chrome/browser/media_gallery/media_gallery_registry.h" #include "chrome/browser/media_gallery/media_galleries_preferences.h"
#include "chrome/browser/profiles/profile_dependency_manager.h" #include "chrome/browser/profiles/profile_dependency_manager.h"
// static // static
MediaGalleryRegistry* MediaGalleryRegistryFactory::GetForProfile( MediaGalleriesPreferences* MediaGalleriesPreferencesFactory::GetForProfile(
Profile* profile) { Profile* profile) {
return static_cast<MediaGalleryRegistry*>( return static_cast<MediaGalleriesPreferences*>(
GetInstance()->GetServiceForProfile(profile, true)); GetInstance()->GetServiceForProfile(profile, true));
} }
// static // static
MediaGalleryRegistryFactory* MediaGalleryRegistryFactory::GetInstance() { MediaGalleriesPreferencesFactory*
return Singleton<MediaGalleryRegistryFactory>::get(); MediaGalleriesPreferencesFactory::GetInstance() {
return Singleton<MediaGalleriesPreferencesFactory>::get();
} }
MediaGalleryRegistryFactory::MediaGalleryRegistryFactory() MediaGalleriesPreferencesFactory::MediaGalleriesPreferencesFactory()
: ProfileKeyedServiceFactory("MediaGalleryRegistry", : ProfileKeyedServiceFactory("MediaGalleriesPreferences",
ProfileDependencyManager::GetInstance()) {} ProfileDependencyManager::GetInstance()) {}
MediaGalleryRegistryFactory::~MediaGalleryRegistryFactory() {} MediaGalleriesPreferencesFactory::~MediaGalleriesPreferencesFactory() {}
ProfileKeyedService* MediaGalleryRegistryFactory::BuildServiceInstanceFor( ProfileKeyedService* MediaGalleriesPreferencesFactory::BuildServiceInstanceFor(
Profile* profile) const { Profile* profile) const {
return new MediaGalleryRegistry(profile); return new MediaGalleriesPreferences(profile);
} }
void MediaGalleryRegistryFactory::RegisterUserPrefs(PrefService* prefs) { void MediaGalleriesPreferencesFactory::RegisterUserPrefs(PrefService* prefs) {
MediaGalleryRegistry::RegisterUserPrefs(prefs); MediaGalleriesPreferences::RegisterUserPrefs(prefs);
} }
bool MediaGalleryRegistryFactory::ServiceRedirectedInIncognito() { bool MediaGalleriesPreferencesFactory::ServiceRedirectedInIncognito() {
return true; return true;
} }
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_
#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h"
class Profile; class Profile;
class MediaGalleryRegistry; class MediaGalleriesPreferences;
// Singleton that owns all MediaGalleryRegistries and associates them with // Singleton that owns all MediaGalleriesPreferences and associates them with
// Profiles. // Profiles.
class MediaGalleryRegistryFactory : public ProfileKeyedServiceFactory { class MediaGalleriesPreferencesFactory : public ProfileKeyedServiceFactory {
public: public:
static MediaGalleryRegistry* GetForProfile(Profile* profile); static MediaGalleriesPreferences* GetForProfile(Profile* profile);
static MediaGalleryRegistryFactory* GetInstance(); static MediaGalleriesPreferencesFactory* GetInstance();
private: private:
friend struct DefaultSingletonTraits<MediaGalleryRegistryFactory>; friend struct DefaultSingletonTraits<MediaGalleriesPreferencesFactory>;
MediaGalleryRegistryFactory(); MediaGalleriesPreferencesFactory();
virtual ~MediaGalleryRegistryFactory(); virtual ~MediaGalleriesPreferencesFactory();
// ProfileKeyedServiceFactory: // ProfileKeyedServiceFactory:
virtual ProfileKeyedService* BuildServiceInstanceFor( virtual ProfileKeyedService* BuildServiceInstanceFor(
...@@ -32,7 +32,7 @@ class MediaGalleryRegistryFactory : public ProfileKeyedServiceFactory { ...@@ -32,7 +32,7 @@ class MediaGalleryRegistryFactory : public ProfileKeyedServiceFactory {
virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE;
virtual bool ServiceRedirectedInIncognito() OVERRIDE; virtual bool ServiceRedirectedInIncognito() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(MediaGalleryRegistryFactory); DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferencesFactory);
}; };
#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_REGISTRY_FACTORY_H_ #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_GALLERIES_PREFERENCES_FACTORY_H_
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/shortcuts_backend_factory.h" #include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/intents/web_intents_registry_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/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/plugin_prefs_factory.h" #include "chrome/browser/plugin_prefs_factory.h"
...@@ -225,7 +225,7 @@ void ProfileDependencyManager::AssertFactoriesBuilt() { ...@@ -225,7 +225,7 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
#if defined(ENABLE_CONFIGURATION_POLICY) #if defined(ENABLE_CONFIGURATION_POLICY)
ManagedModePolicyProviderFactory::GetInstance(); ManagedModePolicyProviderFactory::GetInstance();
#endif #endif
MediaGalleryRegistryFactory::GetInstance(); MediaGalleriesPreferencesFactory::GetInstance();
NTPResourceCacheFactory::GetInstance(); NTPResourceCacheFactory::GetInstance();
PasswordStoreFactory::GetInstance(); PasswordStoreFactory::GetInstance();
PersonalDataManagerFactory::GetInstance(); PersonalDataManagerFactory::GetInstance();
......
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
i18n-content="manage_exceptions"></button> i18n-content="manage_exceptions"></button>
</div> </div>
</section> </section>
<section id="media-gallery-section" hidden> <section id="media-galleries-section" hidden>
<h3 i18n-content="mediaGalleriesSectionLabel"></h3> <h3 i18n-content="mediaGalleriesSectionLabel"></h3>
<div> <div>
<button id="manage-galleries-button" <button id="manage-galleries-button"
......
...@@ -10,15 +10,15 @@ cr.define('options', function() { ...@@ -10,15 +10,15 @@ cr.define('options', function() {
* @constructor * @constructor
* @extends {DeletableItem} * @extends {DeletableItem}
*/ */
function MediaGalleryListItem(galleryInfo) { function MediaGalleriesListItem(galleryInfo) {
var el = cr.doc.createElement('div'); var el = cr.doc.createElement('div');
el.galleryInfo_ = galleryInfo; el.galleryInfo_ = galleryInfo;
el.__proto__ = MediaGalleryListItem.prototype; el.__proto__ = MediaGalleriesListItem.prototype;
el.decorate(); el.decorate();
return el; return el;
} }
MediaGalleryListItem.prototype = { MediaGalleriesListItem.prototype = {
__proto__: DeletableItem.prototype, __proto__: DeletableItem.prototype,
decorate: function() { decorate: function() {
...@@ -31,9 +31,9 @@ cr.define('options', 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, __proto__: DeletableItemList.prototype,
/** @inheritDoc */ /** @inheritDoc */
...@@ -44,7 +44,7 @@ cr.define('options', function() { ...@@ -44,7 +44,7 @@ cr.define('options', function() {
/** @inheritDoc */ /** @inheritDoc */
createItem: function(galleryInfo) { createItem: function(galleryInfo) {
return new MediaGalleryListItem(galleryInfo); return new MediaGalleriesListItem(galleryInfo);
}, },
/** @inheritDoc */ /** @inheritDoc */
...@@ -54,6 +54,6 @@ cr.define('options', function() { ...@@ -54,6 +54,6 @@ cr.define('options', function() {
}; };
return { return {
MediaGalleryList: MediaGalleryList MediaGalleriesList: MediaGalleriesList
}; };
}); });
...@@ -12,15 +12,15 @@ cr.define('options', function() { ...@@ -12,15 +12,15 @@ cr.define('options', function() {
* @constructor * @constructor
* @extends {OptionsPage} * @extends {OptionsPage}
*/ */
function MediaGalleryManager() { function MediaGalleriesManager() {
OptionsPage.call(this, 'manageGalleries', OptionsPage.call(this, 'manageGalleries',
loadTimeData.getString('manageMediaGalleriesTabTitle'), loadTimeData.getString('manageMediaGalleriesTabTitle'),
'manage-media-galleries-overlay'); 'manage-media-galleries-overlay');
} }
cr.addSingletonGetter(MediaGalleryManager); cr.addSingletonGetter(MediaGalleriesManager);
MediaGalleryManager.prototype = { MediaGalleriesManager.prototype = {
__proto__: OptionsPage.prototype, __proto__: OptionsPage.prototype,
/** /**
...@@ -30,7 +30,7 @@ cr.define('options', function() { ...@@ -30,7 +30,7 @@ cr.define('options', function() {
OptionsPage.prototype.initializePage.call(this); OptionsPage.prototype.initializePage.call(this);
this.availableGalleriesList_ = $('available-galleries-list'); this.availableGalleriesList_ = $('available-galleries-list');
options.MediaGalleryList.decorate(this.availableGalleriesList_); options.MediaGalleriesList.decorate(this.availableGalleriesList_);
$('new-media-gallery').addEventListener('click', function() { $('new-media-gallery').addEventListener('click', function() {
chrome.send('addNewGallery'); chrome.send('addNewGallery');
...@@ -61,7 +61,7 @@ cr.define('options', function() { ...@@ -61,7 +61,7 @@ cr.define('options', function() {
setAvailableMediaGalleries_: function(galleries) { setAvailableMediaGalleries_: function(galleries) {
$('available-galleries-list').dataModel = new ArrayDataModel(galleries); $('available-galleries-list').dataModel = new ArrayDataModel(galleries);
// TODO(estade): show this section by default. // 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() { ...@@ -69,14 +69,14 @@ cr.define('options', function() {
[ [
'setAvailableMediaGalleries', 'setAvailableMediaGalleries',
].forEach(function(name) { ].forEach(function(name) {
MediaGalleryManager[name] = function() { MediaGalleriesManager[name] = function() {
var instance = MediaGalleryManager.getInstance(); var instance = MediaGalleriesManager.getInstance();
return instance[name + '_'].apply(instance, arguments); return instance[name + '_'].apply(instance, arguments);
}; };
}); });
// Export // Export
return { return {
MediaGalleryManager: MediaGalleryManager MediaGalleriesManager: MediaGalleriesManager
}; };
}); });
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<include src="cookies_view_app.html"> <include src="cookies_view_app.html">
<include src="handler_options.html"> <include src="handler_options.html">
<include src="language_add_language_overlay.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')"> <if expr="pp_ifdef('chromeos')">
<include src="chromeos/internet_detail.html"> <include src="chromeos/internet_detail.html">
<include src="chromeos/preferred_networks.html"> <include src="chromeos/preferred_networks.html">
......
...@@ -20,7 +20,7 @@ var HomePageOverlay = options.HomePageOverlay; ...@@ -20,7 +20,7 @@ var HomePageOverlay = options.HomePageOverlay;
var ImportDataOverlay = options.ImportDataOverlay; var ImportDataOverlay = options.ImportDataOverlay;
var InstantConfirmOverlay = options.InstantConfirmOverlay; var InstantConfirmOverlay = options.InstantConfirmOverlay;
var LanguageOptions = options.LanguageOptions; var LanguageOptions = options.LanguageOptions;
var MediaGalleryManager = options.MediaGalleryManager; var MediaGalleriesManager = options.MediaGalleriesManager;
var OptionsFocusManager = options.OptionsFocusManager; var OptionsFocusManager = options.OptionsFocusManager;
var OptionsPage = options.OptionsPage; var OptionsPage = options.OptionsPage;
var PasswordManager = options.PasswordManager; var PasswordManager = options.PasswordManager;
...@@ -104,7 +104,7 @@ function load() { ...@@ -104,7 +104,7 @@ function load() {
[$('language-button')]); [$('language-button')]);
OptionsPage.registerOverlay(ManageProfileOverlay.getInstance(), OptionsPage.registerOverlay(ManageProfileOverlay.getInstance(),
BrowserOptions.getInstance()); BrowserOptions.getInstance());
OptionsPage.registerOverlay(MediaGalleryManager.getInstance(), OptionsPage.registerOverlay(MediaGalleriesManager.getInstance(),
ContentSettings.getInstance(), ContentSettings.getInstance(),
[$('manage-galleries-button')]); [$('manage-galleries-button')]);
OptionsPage.registerOverlay(PasswordManager.getInstance(), OptionsPage.registerOverlay(PasswordManager.getInstance(),
......
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
<include src="language_list.js"></include> <include src="language_list.js"></include>
<include src="language_options.js"></include> <include src="language_options.js"></include>
<include src="manage_profile_overlay.js"></include> <include src="manage_profile_overlay.js"></include>
<include src="media_gallery_list.js"></include> <include src="media_galleries_list.js"></include>
<include src="media_gallery_manager_overlay.js"></include> <include src="media_galleries_manager_overlay.js"></include>
<include src="options_focus_manager.js"></include> <include src="options_focus_manager.js"></include>
<include src="password_manager.js"></include> <include src="password_manager.js"></include>
<include src="password_manager_list.js"></include> <include src="password_manager_list.js"></include>
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 "base/bind.h"
#include "chrome/browser/media_gallery/media_gallery_registry.h" #include "chrome/browser/media_gallery/media_galleries_preferences.h"
#include "chrome/browser/media_gallery/media_gallery_registry_factory.h" #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/browser/ui/chrome_select_file_policy.h"
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
namespace options2 { namespace options2 {
MediaGalleryHandler::MediaGalleryHandler() { MediaGalleriesHandler::MediaGalleriesHandler() {
} }
MediaGalleryHandler::~MediaGalleryHandler() { MediaGalleriesHandler::~MediaGalleriesHandler() {
} }
void MediaGalleryHandler::GetLocalizedValues(DictionaryValue* values) { void MediaGalleriesHandler::GetLocalizedValues(DictionaryValue* values) {
DCHECK(values); DCHECK(values);
static OptionsStringResource resources[] = { static OptionsStringResource resources[] = {
...@@ -40,42 +40,42 @@ void MediaGalleryHandler::GetLocalizedValues(DictionaryValue* values) { ...@@ -40,42 +40,42 @@ void MediaGalleryHandler::GetLocalizedValues(DictionaryValue* values) {
IDS_MEDIA_GALLERY_MANAGE_TITLE); IDS_MEDIA_GALLERY_MANAGE_TITLE);
} }
void MediaGalleryHandler::InitializeHandler() { void MediaGalleriesHandler::InitializeHandler() {
if (!MediaGalleryRegistry::UserInteractionIsEnabled()) if (!MediaGalleriesPreferences::UserInteractionIsEnabled())
return; return;
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
pref_change_registrar_.Init(profile->GetPrefs()); pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add(prefs::kMediaGalleryRememberedGalleries, this); pref_change_registrar_.Add(prefs::kMediaGalleriesRememberedGalleries, this);
} }
void MediaGalleryHandler::InitializePage() { void MediaGalleriesHandler::InitializePage() {
if (!MediaGalleryRegistry::UserInteractionIsEnabled()) if (!MediaGalleriesPreferences::UserInteractionIsEnabled())
return; return;
OnGalleriesChanged(); OnGalleriesChanged();
} }
void MediaGalleryHandler::RegisterMessages() { void MediaGalleriesHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"addNewGallery", "addNewGallery",
base::Bind(&MediaGalleryHandler::HandleAddNewGallery, base::Bind(&MediaGalleriesHandler::HandleAddNewGallery,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"forgetGallery", "forgetGallery",
base::Bind(&MediaGalleryHandler::HandleForgetGallery, base::Bind(&MediaGalleriesHandler::HandleForgetGallery,
base::Unretained(this))); base::Unretained(this)));
} }
void MediaGalleryHandler::OnGalleriesChanged() { void MediaGalleriesHandler::OnGalleriesChanged() {
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
const ListValue* list = profile->GetPrefs()->GetList( const ListValue* list = profile->GetPrefs()->GetList(
prefs::kMediaGalleryRememberedGalleries); prefs::kMediaGalleriesRememberedGalleries);
web_ui()->CallJavascriptFunction( 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( SelectFileDialog* dialog = SelectFileDialog::Create(
this, this,
new ChromeSelectFilePolicy(web_ui()->GetWebContents())); new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
...@@ -89,29 +89,31 @@ void MediaGalleryHandler::HandleAddNewGallery(const base::ListValue* args) { ...@@ -89,29 +89,31 @@ void MediaGalleryHandler::HandleAddNewGallery(const base::ListValue* args) {
NULL); NULL);
} }
void MediaGalleryHandler::HandleForgetGallery(const base::ListValue* args) { void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) {
// TODO(estade): use uint64. // TODO(estade): use uint64.
int id; int id;
CHECK(ExtractIntegerValue(args, &id)); CHECK(ExtractIntegerValue(args, &id));
MediaGalleryRegistry* registry = MediaGalleriesPreferences* prefs =
MediaGalleryRegistryFactory::GetForProfile(Profile::FromWebUI(web_ui())); MediaGalleriesPreferencesFactory::GetForProfile(
registry->ForgetGalleryById(id); Profile::FromWebUI(web_ui()));
prefs->ForgetGalleryById(id);
} }
void MediaGalleryHandler::FileSelected( void MediaGalleriesHandler::FileSelected(
const FilePath& path, int index, void* params) { const FilePath& path, int index, void* params) {
MediaGalleryRegistry* registry = MediaGalleriesPreferences* prefs =
MediaGalleryRegistryFactory::GetForProfile(Profile::FromWebUI(web_ui())); MediaGalleriesPreferencesFactory::GetForProfile(
registry->AddGalleryByPath(path); Profile::FromWebUI(web_ui()));
prefs->AddGalleryByPath(path);
} }
void MediaGalleryHandler::Observe( void MediaGalleriesHandler::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
if (type == chrome::NOTIFICATION_PREF_CHANGED && if (type == chrome::NOTIFICATION_PREF_CHANGED &&
*content::Details<std::string>(details).ptr() == *content::Details<std::string>(details).ptr() ==
prefs::kMediaGalleryRememberedGalleries) { prefs::kMediaGalleriesRememberedGalleries) {
OnGalleriesChanged(); OnGalleriesChanged();
} else { } else {
NOTREACHED(); NOTREACHED();
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef 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_GALLERY_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERIES_HANDLER_H_
#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/ui/select_file_dialog.h" #include "chrome/browser/ui/select_file_dialog.h"
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
namespace options2 { namespace options2 {
// Handles messages related to adding or removing media galleries. // Handles messages related to adding or removing media galleries.
class MediaGalleryHandler : public OptionsPageUIHandler, class MediaGalleriesHandler : public OptionsPageUIHandler,
public SelectFileDialog::Listener { public SelectFileDialog::Listener {
public: public:
MediaGalleryHandler(); MediaGalleriesHandler();
virtual ~MediaGalleryHandler(); virtual ~MediaGalleriesHandler();
// OptionsPageUIHandler implementation. // OptionsPageUIHandler implementation.
virtual void GetLocalizedValues(base::DictionaryValue* values) OVERRIDE; virtual void GetLocalizedValues(base::DictionaryValue* values) OVERRIDE;
...@@ -46,9 +46,9 @@ class MediaGalleryHandler : public OptionsPageUIHandler, ...@@ -46,9 +46,9 @@ class MediaGalleryHandler : public OptionsPageUIHandler,
PrefChangeRegistrar pref_change_registrar_; PrefChangeRegistrar pref_change_registrar_;
DISALLOW_COPY_AND_ASSIGN(MediaGalleryHandler); DISALLOW_COPY_AND_ASSIGN(MediaGalleriesHandler);
}; };
} // namespace options2 } // namespace options2
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERY_HANDLER_H_ #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_MEDIA_GALLERIES_HANDLER_H_
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "chrome/browser/ui/webui/options2/import_data_handler.h" #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/language_options_handler.h"
#include "chrome/browser/ui/webui/options2/manage_profile_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/options_sync_setup_handler.h"
#include "chrome/browser/ui/webui/options2/password_manager_handler.h" #include "chrome/browser/ui/webui/options2/password_manager_handler.h"
#include "chrome/browser/ui/webui/options2/search_engine_manager_handler.h" #include "chrome/browser/ui/webui/options2/search_engine_manager_handler.h"
...@@ -235,7 +235,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) ...@@ -235,7 +235,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler()); AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler());
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler()); AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler()); AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler());
AddOptionsPageUIHandler(localized_strings, new MediaGalleryHandler()); AddOptionsPageUIHandler(localized_strings, new MediaGalleriesHandler());
AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler()); AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler());
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
AddOptionsPageUIHandler(localized_strings, AddOptionsPageUIHandler(localized_strings,
......
...@@ -1412,14 +1412,14 @@ ...@@ -1412,14 +1412,14 @@
'browser/media_gallery/media_device_notifications_window_win.h', 'browser/media_gallery/media_device_notifications_window_win.h',
'browser/media_gallery/media_file_system_registry.cc', 'browser/media_gallery/media_file_system_registry.cc',
'browser/media_gallery/media_file_system_registry.h', '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.cc',
'browser/media_gallery/media_gallery_database.h', 'browser/media_gallery/media_gallery_database.h',
'browser/media_gallery/media_gallery_database_types.cc', 'browser/media_gallery/media_gallery_database_types.cc',
'browser/media_gallery/media_gallery_database_types.h', '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.cc',
'browser/memory_details.h', 'browser/memory_details.h',
'browser/memory_details_android.cc', 'browser/memory_details_android.cc',
...@@ -4147,8 +4147,8 @@ ...@@ -4147,8 +4147,8 @@
'browser/ui/webui/options2/language_options_handler_common.h', 'browser/ui/webui/options2/language_options_handler_common.h',
'browser/ui/webui/options2/manage_profile_handler.cc', 'browser/ui/webui/options2/manage_profile_handler.cc',
'browser/ui/webui/options2/manage_profile_handler.h', 'browser/ui/webui/options2/manage_profile_handler.h',
'browser/ui/webui/options2/media_gallery_handler.cc', 'browser/ui/webui/options2/media_galleries_handler.cc',
'browser/ui/webui/options2/media_gallery_handler.h', '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.cc',
'browser/ui/webui/options2/options_sync_setup_handler.h', 'browser/ui/webui/options2/options_sync_setup_handler.h',
'browser/ui/webui/options2/options_ui.cc', 'browser/ui/webui/options2/options_ui.cc',
......
...@@ -1941,12 +1941,12 @@ const char kComponentUpdaterState[] = "component_updater.state"; ...@@ -1941,12 +1941,12 @@ const char kComponentUpdaterState[] = "component_updater.state";
const char kWebIntentsEnabled[] = "webintents.enabled"; const char kWebIntentsEnabled[] = "webintents.enabled";
// The next media gallery ID to assign. // 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 // A list of dictionaries, where each dictionary represents a known media
// gallery. // gallery.
const char kMediaGalleryRememberedGalleries[] = const char kMediaGalleriesRememberedGalleries[] =
"media_gallery.remembered_galleries"; "media_galleries.remembered_galleries";
#if defined(USE_AURA) #if defined(USE_AURA)
// String value corresponding to ash::Shell::ShelfAlignment. // String value corresponding to ash::Shell::ShelfAlignment.
......
...@@ -717,8 +717,8 @@ extern const char kComponentUpdaterState[]; ...@@ -717,8 +717,8 @@ extern const char kComponentUpdaterState[];
extern const char kWebIntentsEnabled[]; extern const char kWebIntentsEnabled[];
extern const char kMediaGalleryUniqueId[]; extern const char kMediaGalleriesUniqueId[];
extern const char kMediaGalleryRememberedGalleries[]; extern const char kMediaGalleriesRememberedGalleries[];
#if defined(USE_AURA) #if defined(USE_AURA)
extern const char kShelfAlignment[]; extern const char kShelfAlignment[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment