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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VIEWS_H_
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.h"
12 #include "ui/views/context_menu_controller.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/window/dialog_delegate.h"
24 // The media galleries scan result view for Views. It will immediately show
26 class MediaGalleriesScanResultDialogViews
27 : public MediaGalleriesScanResultDialog,
28 public views::ButtonListener,
29 public views::ContextMenuController,
30 public views::DialogDelegate {
32 explicit MediaGalleriesScanResultDialogViews(
33 MediaGalleriesScanResultDialogController* controller);
34 virtual ~MediaGalleriesScanResultDialogViews();
36 // MediaGalleriesScanResultDialog implementation:
37 virtual void UpdateResults() OVERRIDE;
39 // views::DialogDelegate implementation:
40 virtual base::string16 GetWindowTitle() 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 base::string16 GetDialogButtonLabel(
46 ui::DialogButton button) const OVERRIDE;
47 virtual ui::ModalType GetModalType() const OVERRIDE;
48 virtual bool Cancel() OVERRIDE;
49 virtual bool Accept() OVERRIDE;
51 // views::ButtonListener implementation:
52 virtual void ButtonPressed(views::Button* sender,
53 const ui::Event& event) OVERRIDE;
55 // views::ContextMenuController implementation:
56 virtual void ShowContextMenuForView(views::View* source,
57 const gfx::Point& point,
58 ui::MenuSourceType source_type) OVERRIDE;
62 views::Checkbox* checkbox;
63 views::ImageButton* folder_viewer_button;
64 views::Label* secondary_text;
66 typedef std::map<MediaGalleryPrefId, GalleryEntry> GalleryViewMap;
68 void InitChildViews();
70 // Adds a checkbox or updates an existing checkbox. Returns true if a new one
72 bool AddOrUpdateScanResult(const MediaGalleryPrefInfo& gallery,
74 views::View* container,
75 int trailing_vertical_space);
77 void ShowContextMenu(const gfx::Point& point,
78 ui::MenuSourceType source_type,
79 MediaGalleryPrefId id);
81 MediaGalleriesScanResultDialogController* controller_;
83 // The containing window (a weak pointer).
84 views::Widget* window_;
86 // The contents of the dialog. Owned by |window_|'s RootView.
87 views::View* contents_;
89 // A map from media gallery ID to the view elements for each gallery.
90 GalleryViewMap gallery_view_map_;
92 // True if the user has pressed accept.
95 scoped_ptr<views::MenuRunner> context_menu_runner_;
97 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogViews);
100 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VIEWS_H_