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

Side by Side Diff: chrome/browser/ui/views/extensions/media_galleries_dialog_views.h

Issue 37553002: [MediaGalleries] Add context menu for forgetting galleries. [views] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dlgfix
Patch Set: . Created 7 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" 11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
12 #include "ui/views/context_menu_controller.h"
12 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
13 #include "ui/views/window/dialog_delegate.h" 14 #include "ui/views/window/dialog_delegate.h"
14 15
16 namespace ui {
17 class MenuModel;
18 }
19
15 namespace views { 20 namespace views {
16 class Checkbox; 21 class Checkbox;
17 class LabelButton; 22 class LabelButton;
23 class MenuRunner;
18 class Widget; 24 class Widget;
19 } 25 }
20 26
27 class GalleryContextMenuModel;
28
21 // The media galleries configuration view for Views. It will immediately show 29 // The media galleries configuration view for Views. It will immediately show
22 // upon construction. 30 // upon construction.
23 class MediaGalleriesDialogViews : public MediaGalleriesDialog, 31 class MediaGalleriesDialogViews : public MediaGalleriesDialog,
24 public views::ButtonListener, 32 public views::ButtonListener,
33 public views::ContextMenuController,
25 public views::DialogDelegate { 34 public views::DialogDelegate {
26 public: 35 public:
27 explicit MediaGalleriesDialogViews( 36 explicit MediaGalleriesDialogViews(
28 MediaGalleriesDialogController* controller); 37 MediaGalleriesDialogController* controller);
29 virtual ~MediaGalleriesDialogViews(); 38 virtual ~MediaGalleriesDialogViews();
30 39
31 // MediaGalleriesDialog implementation: 40 // MediaGalleriesDialog implementation:
32 virtual void UpdateGalleries() OVERRIDE; 41 virtual void UpdateGalleries() OVERRIDE;
33 42
34 // views::DialogDelegate implementation: 43 // views::DialogDelegate implementation:
35 virtual string16 GetWindowTitle() const OVERRIDE; 44 virtual string16 GetWindowTitle() const OVERRIDE;
36 virtual bool ShouldShowWindowTitle() const OVERRIDE; 45 virtual bool ShouldShowWindowTitle() const OVERRIDE;
37 virtual void DeleteDelegate() OVERRIDE; 46 virtual void DeleteDelegate() OVERRIDE;
38 virtual views::Widget* GetWidget() OVERRIDE; 47 virtual views::Widget* GetWidget() OVERRIDE;
39 virtual const views::Widget* GetWidget() const OVERRIDE; 48 virtual const views::Widget* GetWidget() const OVERRIDE;
40 virtual views::View* GetContentsView() OVERRIDE; 49 virtual views::View* GetContentsView() OVERRIDE;
41 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 50 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
42 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 51 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
43 virtual ui::ModalType GetModalType() const OVERRIDE; 52 virtual ui::ModalType GetModalType() const OVERRIDE;
44 virtual views::View* CreateExtraView() OVERRIDE; 53 virtual views::View* CreateExtraView() OVERRIDE;
45 virtual bool Cancel() OVERRIDE; 54 virtual bool Cancel() OVERRIDE;
46 virtual bool Accept() OVERRIDE; 55 virtual bool Accept() OVERRIDE;
47 virtual views::NonClientFrameView* CreateNonClientFrameView( 56 virtual views::NonClientFrameView* CreateNonClientFrameView(
48 views::Widget* widget) OVERRIDE; 57 views::Widget* widget) OVERRIDE;
49 58
50 // views::ButtonListener implementation: 59 // views::ButtonListener implementation:
51 virtual void ButtonPressed(views::Button* sender, 60 virtual void ButtonPressed(views::Button* sender,
52 const ui::Event& event) OVERRIDE; 61 const ui::Event& event) OVERRIDE;
53 62
63 // views::ContextMenuController implementation:
64 virtual void ShowContextMenuForView(views::View* source,
65 const gfx::Point& point,
66 ui::MenuSourceType source_type) OVERRIDE;
67
68 // Command from the context menu to forget a gallery.
69 void DidForgetGallery(MediaGalleryPrefId id);
70
54 private: 71 private:
55 typedef std::map<MediaGalleryPrefId, views::Checkbox*> CheckboxMap; 72 typedef std::map<MediaGalleryPrefId, views::Checkbox*> CheckboxMap;
56 typedef std::map<views::Checkbox*, MediaGalleryPrefInfo> NewCheckboxMap; 73 typedef std::map<views::Checkbox*, MediaGalleryPrefInfo> NewCheckboxMap;
57 74
58 void InitChildViews(); 75 void InitChildViews();
59 76
60 // Adds a checkbox or updates an existing checkbox. Returns true if a new one 77 // Adds a checkbox or updates an existing checkbox. Returns true if a new one
61 // was added. 78 // was added.
62 bool AddOrUpdateGallery(const MediaGalleryPrefInfo& gallery, 79 bool AddOrUpdateGallery(const MediaGalleryPrefInfo& gallery,
63 bool permitted, 80 bool permitted,
64 views::View* container, 81 views::View* container,
65 int trailing_vertical_space); 82 int trailing_vertical_space);
66 83
84 void ShowContextMenu(const gfx::Point& point,
85 ui::MenuSourceType source_type,
86 MediaGalleryPrefId id);
87
67 MediaGalleriesDialogController* controller_; 88 MediaGalleriesDialogController* controller_;
68 89
69 // The containing window (a weak pointer). 90 // The containing window (a weak pointer).
70 views::Widget* window_; 91 views::Widget* window_;
71 92
72 // The contents of the dialog. Owned by |window_|'s RootView. 93 // The contents of the dialog. Owned by |window_|'s RootView.
73 views::View* contents_; 94 views::View* contents_;
74 95
75 // A map from media gallery ID to views::Checkbox view. 96 // A map from media gallery ID to views::Checkbox view.
76 CheckboxMap checkbox_map_; 97 CheckboxMap checkbox_map_;
77 98
78 NewCheckboxMap new_checkbox_map_; 99 NewCheckboxMap new_checkbox_map_;
79 100
80 // Pointer to the button to add a new gallery. Owned by parent in 101 // Pointer to the button to add a new gallery. Owned by parent in
81 // the dialog views tree. 102 // the dialog views tree.
82 views::LabelButton* add_gallery_button_; 103 views::LabelButton* add_gallery_button_;
83 104
84 // This tracks whether the confirm button can be clicked. It starts as false 105 // This tracks whether the confirm button can be clicked. It starts as false
85 // if no checkboxes are ticked. After there is any interaction, or some 106 // if no checkboxes are ticked. After there is any interaction, or some
86 // checkboxes start checked, this will be true. 107 // checkboxes start checked, this will be true.
87 bool confirm_available_; 108 bool confirm_available_;
88 109
89 // True if the user has pressed accept. 110 // True if the user has pressed accept.
90 bool accepted_; 111 bool accepted_;
91 112
113 GalleryContextMenuModel* gallery_menu_model_;
114 scoped_ptr<ui::MenuModel> context_menu_model_;
115 scoped_ptr<views::MenuRunner> context_menu_runner_;
116
92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogViews); 117 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogViews);
93 }; 118 };
94 119
95 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 120 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698