| Index: chrome/browser/media_galleries/media_galleries_permission_controller.h
|
| diff --git a/chrome/browser/media_galleries/media_galleries_dialog_controller.h b/chrome/browser/media_galleries/media_galleries_permission_controller.h
|
| similarity index 65%
|
| copy from chrome/browser/media_galleries/media_galleries_dialog_controller.h
|
| copy to chrome/browser/media_galleries/media_galleries_permission_controller.h
|
| index 14abc3af3fd9f33d54e2fff8eb28001487783c41..066a45d289aa681df59b7e2796462f2c64ba6e58 100644
|
| --- a/chrome/browser/media_galleries/media_galleries_dialog_controller.h
|
| +++ b/chrome/browser/media_galleries/media_galleries_permission_controller.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_GALLERIES_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
|
| -#define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
|
| +#ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_
|
| +#define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_
|
|
|
| #include <map>
|
| #include <string>
|
| @@ -12,6 +12,7 @@
|
| #include "base/callback.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string16.h"
|
| +#include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
|
| #include "chrome/browser/media_galleries/media_galleries_preferences.h"
|
| #include "components/storage_monitor/removable_storage_observer.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| @@ -42,113 +43,65 @@ class Profile;
|
| // used, the GalleryDialogId type is used where fake ids are needed.
|
| typedef MediaGalleryPrefId GalleryDialogId;
|
|
|
| -// The view.
|
| -class MediaGalleriesDialog {
|
| - public:
|
| - virtual ~MediaGalleriesDialog();
|
| -
|
| - // Tell the dialog to update its display list of galleries.
|
| - virtual void UpdateGalleries() = 0;
|
| -
|
| - // Constructs a platform-specific dialog owned and controlled by |controller|.
|
| - static MediaGalleriesDialog* Create(
|
| - MediaGalleriesDialogController* controller);
|
| -};
|
| -
|
| -// The controller is responsible for handling the logic of the dialog and
|
| -// interfacing with the model (i.e., MediaGalleriesPreferences). It shows
|
| -// the dialog and owns itself.
|
| -class MediaGalleriesDialogController
|
| - : public ui::SelectFileDialog::Listener,
|
| +class MediaGalleriesPermissionController
|
| + : public MediaGalleriesDialogController,
|
| + public ui::SelectFileDialog::Listener,
|
| public storage_monitor::RemovableStorageObserver,
|
| public MediaGalleriesPreferences::GalleryChangeObserver {
|
| public:
|
| - struct GalleryPermission {
|
| - GalleryPermission(GalleryDialogId gallery_id,
|
| - const MediaGalleryPrefInfo& pref_info,
|
| - bool allowed)
|
| - : gallery_id(gallery_id),
|
| - pref_info(pref_info),
|
| - allowed(allowed) {
|
| - }
|
| - GalleryPermission() {}
|
| -
|
| - GalleryDialogId gallery_id;
|
| - MediaGalleryPrefInfo pref_info;
|
| - bool allowed;
|
| - };
|
| -
|
| - typedef std::vector<GalleryPermission> GalleryPermissionsVector;
|
| -
|
| // The constructor creates a dialog controller which owns itself.
|
| - MediaGalleriesDialogController(content::WebContents* web_contents,
|
| - const extensions::Extension& extension,
|
| - const base::Closure& on_finish);
|
| -
|
| - // The title of the dialog view.
|
| - base::string16 GetHeader() const;
|
| -
|
| - // Explanatory text directly below the title.
|
| - base::string16 GetSubtext() const;
|
| -
|
| - // Header for unattached devices part of the dialog.
|
| - base::string16 GetUnattachedLocationsHeader() const;
|
| -
|
| - // Initial state of whether the dialog's confirmation button will be enabled.
|
| - bool IsAcceptAllowed() const;
|
| -
|
| - // Get the set of permissions to attached galleries.
|
| - virtual GalleryPermissionsVector AttachedPermissions() const;
|
| -
|
| - // Get the set of permissions to unattached galleries.
|
| - virtual GalleryPermissionsVector UnattachedPermissions() const;
|
| -
|
| - // Called when the add-folder button in the dialog is clicked.
|
| - virtual void OnAddFolderClicked();
|
| -
|
| - // A checkbox beside a gallery permission was checked. The full set
|
| - // of gallery permissions checkbox settings is sent on every checkbox toggle.
|
| - virtual void DidToggleGallery(GalleryDialogId gallery_id, bool enabled);
|
| -
|
| - // The forget command in the context menu was selected.
|
| - virtual void DidForgetGallery(GalleryDialogId gallery_id);
|
| -
|
| - // The dialog is being deleted.
|
| - virtual void DialogFinished(bool accepted);
|
| -
|
| - virtual content::WebContents* web_contents();
|
| -
|
| - ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id);
|
| + MediaGalleriesPermissionController(content::WebContents* web_contents,
|
| + const extensions::Extension& extension,
|
| + const base::Closure& on_finish);
|
| +
|
| + // MediaGalleriesDialogController implementation.
|
| + virtual base::string16 GetHeader() const OVERRIDE;
|
| + virtual base::string16 GetSubtext() const OVERRIDE;
|
| + virtual bool IsAcceptAllowed() const OVERRIDE;
|
| + virtual bool ShowFolderViewer(const Entry& entry) const OVERRIDE;
|
| + virtual std::vector<base::string16> GetSectionHeaders() const OVERRIDE;
|
| + virtual Entries GetSectionEntries(size_t index) const OVERRIDE;
|
| + virtual base::string16 GetAuxilliaryButtonText() const OVERRIDE;
|
| + virtual void OnAuxilliaryButtonClicked() OVERRIDE;
|
| + virtual void DidToggleEntry(GalleryDialogId gallery_id,
|
| + bool selected) OVERRIDE;
|
| + virtual void DidClickOpenFolderViewer(GalleryDialogId gallery_id) OVERRIDE;
|
| + virtual void DidForgetEntry(GalleryDialogId gallery_id) OVERRIDE;
|
| + virtual base::string16 GetAcceptButtonText() const OVERRIDE;
|
| + virtual void DialogFinished(bool accepted) OVERRIDE;
|
| + virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) OVERRIDE;
|
| + virtual content::WebContents* web_contents() OVERRIDE;
|
|
|
| protected:
|
| - friend class MediaGalleriesDialogControllerTest;
|
| + friend class MediaGalleriesPermissionControllerTest;
|
|
|
| typedef base::Callback<MediaGalleriesDialog* (
|
| MediaGalleriesDialogController*)> CreateDialogCallback;
|
|
|
| // For use with tests.
|
| - MediaGalleriesDialogController(
|
| + MediaGalleriesPermissionController(
|
| const extensions::Extension& extension,
|
| MediaGalleriesPreferences* preferences,
|
| const CreateDialogCallback& create_dialog_callback,
|
| const base::Closure& on_finish);
|
|
|
| - virtual ~MediaGalleriesDialogController();
|
| + virtual ~MediaGalleriesPermissionController();
|
|
|
| private:
|
| // This type keeps track of media galleries already known to the prefs system.
|
| - typedef std::map<GalleryDialogId, GalleryPermission>
|
| - GalleryPermissionsMap;
|
| + typedef std::map<GalleryDialogId, Entry> GalleryPermissionsMap;
|
|
|
| class DialogIdMap {
|
| public:
|
| DialogIdMap();
|
| ~DialogIdMap();
|
| GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id);
|
| + MediaGalleryPrefId GetPrefId(GalleryDialogId id);
|
|
|
| private:
|
| GalleryDialogId next_dialog_id_;
|
| - std::map<GalleryDialogId, MediaGalleryPrefId> mapping_;
|
| + std::map<MediaGalleryPrefId, GalleryDialogId> back_map_;
|
| + std::vector<MediaGalleryPrefId> forward_mapping_;
|
| DISALLOW_COPY_AND_ASSIGN(DialogIdMap);
|
| };
|
|
|
| @@ -210,11 +163,8 @@ class MediaGalleriesDialogController
|
| // Updates the model and view when a device is attached or detached.
|
| void UpdateGalleriesOnDeviceEvent(const std::string& device_id);
|
|
|
| - // Return a sorted vector of either attached or unattached gallery
|
| - // permissions.
|
| - GalleryPermissionsVector FillPermissions(bool attached) const;
|
| -
|
| GalleryDialogId GetDialogId(MediaGalleryPrefId pref_id);
|
| + MediaGalleryPrefId GetPrefId(GalleryDialogId id);
|
|
|
| Profile* GetProfile();
|
|
|
| @@ -259,7 +209,7 @@ class MediaGalleriesDialogController
|
| // Creates the dialog. Only changed for unit tests.
|
| CreateDialogCallback create_dialog_callback_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogController);
|
| + DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPermissionController);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_DIALOG_CONTROLLER_H_
|
| +#endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_GALLERIES_PERMISSION_CONTROLLER_H_
|
|
|