Fix Views web-modal dialog widget creation.
[chromium-blink-merge.git] / chrome / browser / ui / views / extensions / media_galleries_scan_result_dialog_views.h
blobd44aa5f4bb4eb59f5b6090e512ed97dd363ac55f
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_
8 #include <map>
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"
16 namespace views {
17 class Checkbox;
18 class ImageButton;
19 class Label;
20 class MenuRunner;
21 class Widget;
24 class MediaGalleryCheckboxView;
26 // The media galleries scan result view for Views. It will immediately show
27 // upon construction.
28 class MediaGalleriesScanResultDialogViews
29 : public MediaGalleriesScanResultDialog,
30 public views::ButtonListener,
31 public views::ContextMenuController,
32 public views::DialogDelegate {
33 public:
34 explicit MediaGalleriesScanResultDialogViews(
35 MediaGalleriesScanResultDialogController* controller);
36 virtual ~MediaGalleriesScanResultDialogViews();
38 // MediaGalleriesScanResultDialog implementation:
39 virtual void UpdateResults() OVERRIDE;
41 // views::DialogDelegate implementation:
42 virtual base::string16 GetWindowTitle() const OVERRIDE;
43 virtual void DeleteDelegate() OVERRIDE;
44 virtual views::Widget* GetWidget() OVERRIDE;
45 virtual const views::Widget* GetWidget() const OVERRIDE;
46 virtual views::View* GetContentsView() OVERRIDE;
47 virtual base::string16 GetDialogButtonLabel(
48 ui::DialogButton button) const OVERRIDE;
49 virtual ui::ModalType GetModalType() const OVERRIDE;
50 virtual bool Cancel() OVERRIDE;
51 virtual bool Accept() OVERRIDE;
53 // views::ButtonListener implementation:
54 virtual void ButtonPressed(views::Button* sender,
55 const ui::Event& event) OVERRIDE;
57 // views::ContextMenuController implementation:
58 virtual void ShowContextMenuForView(views::View* source,
59 const gfx::Point& point,
60 ui::MenuSourceType source_type) OVERRIDE;
62 private:
63 typedef std::map<MediaGalleryPrefId, MediaGalleryCheckboxView*>
64 GalleryViewMap;
66 void InitChildViews();
68 // Adds a checkbox or updates an existing checkbox. Returns true if a new one
69 // was added.
70 bool AddOrUpdateScanResult(const MediaGalleryPrefInfo& gallery,
71 bool selected,
72 views::View* container,
73 int trailing_vertical_space);
75 void ShowContextMenu(const gfx::Point& point,
76 ui::MenuSourceType source_type,
77 MediaGalleryPrefId id);
79 // MediaGalleriesScanResultDialog implementation:
80 virtual void AcceptDialogForTesting() OVERRIDE;
82 MediaGalleriesScanResultDialogController* controller_;
84 // The contents of the dialog. Owned by the view hierarchy.
85 views::View* contents_;
87 // A map from media gallery ID to the view elements for each gallery.
88 GalleryViewMap gallery_view_map_;
90 // True if the user has pressed accept.
91 bool accepted_;
93 scoped_ptr<views::MenuRunner> context_menu_runner_;
95 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogViews);
98 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VIEWS_H_