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

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

Issue 148093011: Abstract media galleries context menu code and use it in scan result dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits & rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SCAN_RESULT_DIALOG_VI EWS_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VI EWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VI EWS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VI EWS_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_scan_result_dialog_cont roller.h" 11 #include "chrome/browser/media_galleries/media_galleries_scan_result_dialog_cont roller.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
15 namespace views { 16 namespace views {
16 class Checkbox; 17 class Checkbox;
17 class ImageButton; 18 class ImageButton;
18 class Label; 19 class Label;
20 class MenuRunner;
19 class Widget; 21 class Widget;
20 } 22 }
21 23
22 // The media galleries scan result view for Views. It will immediately show 24 // The media galleries scan result view for Views. It will immediately show
23 // upon construction. 25 // upon construction.
24 class MediaGalleriesScanResultDialogViews 26 class MediaGalleriesScanResultDialogViews
25 : public MediaGalleriesScanResultDialog, 27 : public MediaGalleriesScanResultDialog,
26 public views::ButtonListener, 28 public views::ButtonListener,
29 public views::ContextMenuController,
27 public views::DialogDelegate { 30 public views::DialogDelegate {
28 public: 31 public:
29 explicit MediaGalleriesScanResultDialogViews( 32 explicit MediaGalleriesScanResultDialogViews(
30 MediaGalleriesScanResultDialogController* controller); 33 MediaGalleriesScanResultDialogController* controller);
31 virtual ~MediaGalleriesScanResultDialogViews(); 34 virtual ~MediaGalleriesScanResultDialogViews();
32 35
33 // MediaGalleriesScanResultDialog implementation: 36 // MediaGalleriesScanResultDialog implementation:
34 virtual void UpdateResults() OVERRIDE; 37 virtual void UpdateResults() OVERRIDE;
35 38
36 // views::DialogDelegate implementation: 39 // views::DialogDelegate implementation:
37 virtual base::string16 GetWindowTitle() const OVERRIDE; 40 virtual base::string16 GetWindowTitle() const OVERRIDE;
38 virtual void DeleteDelegate() OVERRIDE; 41 virtual void DeleteDelegate() OVERRIDE;
39 virtual views::Widget* GetWidget() OVERRIDE; 42 virtual views::Widget* GetWidget() OVERRIDE;
40 virtual const views::Widget* GetWidget() const OVERRIDE; 43 virtual const views::Widget* GetWidget() const OVERRIDE;
41 virtual views::View* GetContentsView() OVERRIDE; 44 virtual views::View* GetContentsView() OVERRIDE;
42 virtual base::string16 GetDialogButtonLabel( 45 virtual base::string16 GetDialogButtonLabel(
43 ui::DialogButton button) const OVERRIDE; 46 ui::DialogButton button) const OVERRIDE;
44 virtual ui::ModalType GetModalType() const OVERRIDE; 47 virtual ui::ModalType GetModalType() const OVERRIDE;
45 virtual bool Cancel() OVERRIDE; 48 virtual bool Cancel() OVERRIDE;
46 virtual bool Accept() OVERRIDE; 49 virtual bool Accept() OVERRIDE;
47 virtual views::NonClientFrameView* CreateNonClientFrameView( 50 virtual views::NonClientFrameView* CreateNonClientFrameView(
48 views::Widget* widget) OVERRIDE; 51 views::Widget* widget) OVERRIDE;
49 52
50 // views::ButtonListener implementation: 53 // views::ButtonListener implementation:
51 virtual void ButtonPressed(views::Button* sender, 54 virtual void ButtonPressed(views::Button* sender,
52 const ui::Event& event) OVERRIDE; 55 const ui::Event& event) OVERRIDE;
53 56
57 // views::ContextMenuController implementation:
58 virtual void ShowContextMenuForView(views::View* source,
59 const gfx::Point& point,
60 ui::MenuSourceType source_type) OVERRIDE;
61
54 private: 62 private:
55 struct GalleryEntry { 63 struct GalleryEntry {
56 views::Checkbox* checkbox; 64 views::Checkbox* checkbox;
57 views::ImageButton* folder_viewer_button; 65 views::ImageButton* folder_viewer_button;
58 views::Label* secondary_text; 66 views::Label* secondary_text;
59 }; 67 };
60 typedef std::map<MediaGalleryPrefId, GalleryEntry> GalleryViewMap; 68 typedef std::map<MediaGalleryPrefId, GalleryEntry> GalleryViewMap;
61 69
62 void InitChildViews(); 70 void InitChildViews();
63 71
64 // 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
65 // was added. 73 // was added.
66 bool AddOrUpdateScanResult(const MediaGalleryPrefInfo& gallery, 74 bool AddOrUpdateScanResult(const MediaGalleryPrefInfo& gallery,
67 bool selected, 75 bool selected,
68 views::View* container, 76 views::View* container,
69 int trailing_vertical_space); 77 int trailing_vertical_space);
70 78
79 void ShowContextMenu(const gfx::Point& point,
80 ui::MenuSourceType source_type,
81 MediaGalleryPrefId id);
82
71 MediaGalleriesScanResultDialogController* controller_; 83 MediaGalleriesScanResultDialogController* controller_;
72 84
73 // The containing window (a weak pointer). 85 // The containing window (a weak pointer).
74 views::Widget* window_; 86 views::Widget* window_;
75 87
76 // The contents of the dialog. Owned by |window_|'s RootView. 88 // The contents of the dialog. Owned by |window_|'s RootView.
77 views::View* contents_; 89 views::View* contents_;
78 90
79 // A map from media gallery ID to the view elements for each gallery. 91 // A map from media gallery ID to the view elements for each gallery.
80 GalleryViewMap gallery_view_map_; 92 GalleryViewMap gallery_view_map_;
81 93
82 // True if the user has pressed accept. 94 // True if the user has pressed accept.
83 bool accepted_; 95 bool accepted_;
84 96
97 scoped_ptr<views::MenuRunner> context_menu_runner_;
98
85 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogViews); 99 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogViews);
86 }; 100 };
87 101
88 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG _VIEWS_H_ 102 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG _VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698