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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 7 8 #include <map> 9 10 #include "base/compiler_specific.h" 11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" 12 #include "ui/views/controls/button/button.h" 13 #include "ui/views/window/dialog_delegate.h" 14 15 namespace views { 16 class Checkbox; 17 class LabelButton; 18 class Widget; 19 } 20 21 namespace chrome { 22 23 // The media galleries configuration view for Views. It will immediately show 24 // upon construction. 25 class MediaGalleriesDialogViews : public MediaGalleriesDialog, 26 public views::DialogDelegate, 27 public views::ButtonListener { 28 public: 29 explicit MediaGalleriesDialogViews( 30 MediaGalleriesDialogController* controller); 31 virtual ~MediaGalleriesDialogViews(); 32 33 // MediaGalleriesDialog implementation: 34 virtual void UpdateGallery(const MediaGalleryPrefInfo& gallery, 35 bool permitted) OVERRIDE; 36 virtual void ForgetGallery(MediaGalleryPrefId gallery) OVERRIDE; 37 38 // views::DialogDelegate implementation: 39 virtual string16 GetWindowTitle() const OVERRIDE; 40 virtual bool ShouldShowWindowTitle() const OVERRIDE; 41 virtual void DeleteDelegate() OVERRIDE; 42 virtual views::Widget* GetWidget() OVERRIDE; 43 virtual const views::Widget* GetWidget() const OVERRIDE; 44 virtual views::View* GetContentsView() OVERRIDE; 45 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 46 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 47 virtual ui::ModalType GetModalType() const OVERRIDE; 48 virtual views::View* CreateExtraView() OVERRIDE; 49 virtual bool Cancel() OVERRIDE; 50 virtual bool Accept() OVERRIDE; 51 virtual views::NonClientFrameView* CreateNonClientFrameView( 52 views::Widget* widget) OVERRIDE; 53 54 // views::ButtonListener implementation: 55 virtual void ButtonPressed(views::Button* sender, 56 const ui::Event& event) OVERRIDE; 57 58 private: 59 typedef std::map<MediaGalleryPrefId, views::Checkbox*> CheckboxMap; 60 61 void InitChildViews(); 62 63 // Adds a checkbox or updates an existing checkbox. Returns true if a new one 64 // was added. 65 bool AddOrUpdateGallery(const MediaGalleryPrefInfo& gallery, 66 bool permitted, 67 views::View* container, 68 int trailing_vertical_space); 69 70 MediaGalleriesDialogController* controller_; 71 72 // The containing window (a weak pointer). 73 views::Widget* window_; 74 75 // The contents of the dialog. Owned by |window_|'s RootView. 76 views::View* contents_; 77 78 // A map from media gallery ID to views::Checkbox view. 79 CheckboxMap checkbox_map_; 80 81 // Pointer to the button to add a new gallery. Owned by parent in 82 // the dialog views tree. 83 views::LabelButton* add_gallery_button_; 84 85 // This tracks whether the confirm button can be clicked. It starts as false 86 // if no checkboxes are ticked. After there is any interaction, or some 87 // checkboxes start checked, this will be true. 88 bool confirm_available_; 89 90 // True if the user has pressed accept. 91 bool accepted_; 92 93 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogViews); 94 }; 95 96 } // namespace chrome 97 98 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 99