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

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: Inline menu text command Created 7 years, 1 month 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
21 // The media galleries configuration view for Views. It will immediately show 27 // The media galleries configuration view for Views. It will immediately show
22 // upon construction. 28 // upon construction.
23 class MediaGalleriesDialogViews : public MediaGalleriesDialog, 29 class MediaGalleriesDialogViews : public MediaGalleriesDialog,
24 public views::ButtonListener, 30 public views::ButtonListener,
31 public views::ContextMenuController,
25 public views::DialogDelegate { 32 public views::DialogDelegate {
26 public: 33 public:
27 explicit MediaGalleriesDialogViews( 34 explicit MediaGalleriesDialogViews(
28 MediaGalleriesDialogController* controller); 35 MediaGalleriesDialogController* controller);
29 virtual ~MediaGalleriesDialogViews(); 36 virtual ~MediaGalleriesDialogViews();
30 37
31 // MediaGalleriesDialog implementation: 38 // MediaGalleriesDialog implementation:
32 virtual void UpdateGalleries() OVERRIDE; 39 virtual void UpdateGalleries() OVERRIDE;
33 40
34 // views::DialogDelegate implementation: 41 // views::DialogDelegate implementation:
35 virtual string16 GetWindowTitle() const OVERRIDE; 42 virtual string16 GetWindowTitle() const OVERRIDE;
36 virtual bool ShouldShowWindowTitle() const OVERRIDE; 43 virtual bool ShouldShowWindowTitle() const OVERRIDE;
37 virtual void DeleteDelegate() OVERRIDE; 44 virtual void DeleteDelegate() OVERRIDE;
38 virtual views::Widget* GetWidget() OVERRIDE; 45 virtual views::Widget* GetWidget() OVERRIDE;
39 virtual const views::Widget* GetWidget() const OVERRIDE; 46 virtual const views::Widget* GetWidget() const OVERRIDE;
40 virtual views::View* GetContentsView() OVERRIDE; 47 virtual views::View* GetContentsView() OVERRIDE;
41 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 48 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
42 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 49 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
43 virtual ui::ModalType GetModalType() const OVERRIDE; 50 virtual ui::ModalType GetModalType() const OVERRIDE;
44 virtual views::View* CreateExtraView() OVERRIDE; 51 virtual views::View* CreateExtraView() OVERRIDE;
45 virtual bool Cancel() OVERRIDE; 52 virtual bool Cancel() OVERRIDE;
46 virtual bool Accept() OVERRIDE; 53 virtual bool Accept() OVERRIDE;
47 virtual views::NonClientFrameView* CreateNonClientFrameView( 54 virtual views::NonClientFrameView* CreateNonClientFrameView(
48 views::Widget* widget) OVERRIDE; 55 views::Widget* widget) OVERRIDE;
49 56
50 // views::ButtonListener implementation: 57 // views::ButtonListener implementation:
51 virtual void ButtonPressed(views::Button* sender, 58 virtual void ButtonPressed(views::Button* sender,
52 const ui::Event& event) OVERRIDE; 59 const ui::Event& event) OVERRIDE;
53 60
61 // views::ContextMenuController implementation:
62 virtual void ShowContextMenuForView(views::View* source,
63 const gfx::Point& point,
64 ui::MenuSourceType source_type) OVERRIDE;
65
54 private: 66 private:
55 typedef std::map<MediaGalleryPrefId, views::Checkbox*> CheckboxMap; 67 typedef std::map<MediaGalleryPrefId, views::Checkbox*> CheckboxMap;
56 typedef std::map<views::Checkbox*, MediaGalleryPrefInfo> NewCheckboxMap; 68 typedef std::map<views::Checkbox*, MediaGalleryPrefInfo> NewCheckboxMap;
57 69
58 void InitChildViews(); 70 void InitChildViews();
59 71
60 // Adds a checkbox or updates an existing checkbox. Returns true if a new one 72 // Adds a checkbox or updates an existing checkbox. Returns true if a new one
61 // was added. 73 // was added.
62 bool AddOrUpdateGallery(const MediaGalleryPrefInfo& gallery, 74 bool AddOrUpdateGallery(const MediaGalleryPrefInfo& gallery,
63 bool permitted, 75 bool permitted,
64 views::View* container, 76 views::View* container,
65 int trailing_vertical_space); 77 int trailing_vertical_space);
66 78
79 void ShowContextMenu(const gfx::Point& point,
80 ui::MenuSourceType source_type,
81 MediaGalleryPrefId id);
82
67 MediaGalleriesDialogController* controller_; 83 MediaGalleriesDialogController* controller_;
68 84
69 // The containing window (a weak pointer). 85 // The containing window (a weak pointer).
70 views::Widget* window_; 86 views::Widget* window_;
71 87
72 // The contents of the dialog. Owned by |window_|'s RootView. 88 // The contents of the dialog. Owned by |window_|'s RootView.
73 views::View* contents_; 89 views::View* contents_;
74 90
75 // A map from media gallery ID to views::Checkbox view. 91 // A map from media gallery ID to views::Checkbox view.
76 CheckboxMap checkbox_map_; 92 CheckboxMap checkbox_map_;
77 93
78 NewCheckboxMap new_checkbox_map_; 94 NewCheckboxMap new_checkbox_map_;
79 95
80 // Pointer to the button to add a new gallery. Owned by parent in 96 // Pointer to the button to add a new gallery. Owned by parent in
81 // the dialog views tree. 97 // the dialog views tree.
82 views::LabelButton* add_gallery_button_; 98 views::LabelButton* add_gallery_button_;
83 99
84 // This tracks whether the confirm button can be clicked. It starts as false 100 // 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 101 // if no checkboxes are ticked. After there is any interaction, or some
86 // checkboxes start checked, this will be true. 102 // checkboxes start checked, this will be true.
87 bool confirm_available_; 103 bool confirm_available_;
88 104
89 // True if the user has pressed accept. 105 // True if the user has pressed accept.
90 bool accepted_; 106 bool accepted_;
91 107
108 scoped_ptr<views::MenuRunner> context_menu_runner_;
109
92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogViews); 110 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogViews);
93 }; 111 };
94 112
95 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_ 113 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_DIALOG_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698