Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2229)

Unified Diff: chrome/browser/media_gallery/media_galleries_dialog_controller.h

Issue 12095074: Media Galleries: Keep media gallery permission dialogs in sync with the gallery (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix nit Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_dialog_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media_gallery/media_galleries_dialog_controller.h
===================================================================
--- chrome/browser/media_gallery/media_galleries_dialog_controller.h (revision 181443)
+++ chrome/browser/media_gallery/media_galleries_dialog_controller.h (working copy)
@@ -33,12 +33,16 @@
public:
virtual ~MediaGalleriesDialog();
- // Updates the checkbox state for |gallery|. |gallery| is owned by the
- // controller and is guaranteed to live longer than the dialog. If the
- // checkbox doesn't already exist, it should be created.
+ // Updates the entry for |gallery| with the checkbox set to the value in
+ // |permitted|. |gallery| is owned by the controller and is guaranteed to
+ // live longer than the dialog. If the entry does not already exist, it
+ // should be created.
virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery,
bool permitted) = 0;
+ // If there exists an entry for |gallery|, it should be removed.
+ virtual void ForgetGallery(const MediaGalleryPrefInfo* gallery) = 0;
+
// Constructs a platform-specific dialog owned and controlled by |controller|.
static MediaGalleriesDialog* Create(
MediaGalleriesDialogController* controller);
@@ -49,7 +53,8 @@
// the dialog and owns itself.
class MediaGalleriesDialogController
: public ui::SelectFileDialog::Listener,
- public RemovableStorageObserver {
+ public RemovableStorageObserver,
+ public MediaGalleriesPreferences::GalleryChangeObserver {
public:
// A fancy pair.
struct GalleryPermission {
@@ -101,19 +106,32 @@
int index,
void* params) OVERRIDE;
- // RemovableStorageObserver implementation:
+ // RemovableStorageObserver implementation.
+ // Used to keep dialog in sync with removable device status.
virtual void OnRemovableStorageAttached(
const RemovableStorageNotifications::StorageInfo& info) OVERRIDE;
virtual void OnRemovableStorageDetached(
const RemovableStorageNotifications::StorageInfo& info) OVERRIDE;
- // Populates |known_galleries_|.
+ // MediaGalleriesPreferences::GalleryChangeObserver implementation.
+ // Used to keep the dialog in sync when the preferences change.
+ virtual void OnGalleryChanged(MediaGalleriesPreferences* pref,
+ const std::string& extension_id) OVERRIDE;
+
+ // Populates |known_galleries_| from |preferences_|. Subsequent calls merge
+ // into |known_galleries_| and do not change permissions for user toggled
+ // galleries.
void InitializePermissions();
// Saves state of |known_galleries_| and |new_galleries_| to model.
void SavePermissions();
- // Update the model and view when a device is attached or detached.
+ // Updates the model and view when |preferences_| changes. Some of the
+ // possible changes includes a gallery getting blacklisted, or a new
+ // auto detected gallery becoming available.
+ void UpdateGalleriesOnPreferencesEvent();
+
+ // Updates the model and view when a device is attached or detached.
void UpdateGalleriesOnDeviceEvent(const std::string& device_id);
// The web contents from which the request originated.
@@ -126,12 +144,19 @@
// This map excludes those galleries which have been blacklisted; it only
// counts active known galleries.
KnownGalleryPermissions known_galleries_;
+
+ // Galleries in |known_galleries_| that the user have toggled.
+ MediaGalleryPrefIdSet toggled_galleries_;
+
+ // Map of new galleries the user added, but have not saved. This list should
+ // never overlap with |known_galleries_|.
NewGalleryPermissions new_galleries_;
- // We run this callback when done.
+ // Callback to run when the dialog closes.
base::Closure on_finish_;
// The model that tracks galleries and extensions' permissions.
+ // This is the authoritative source for gallery information.
MediaGalleriesPreferences* preferences_;
// The view that's showing.
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698