Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / extensions / media_galleries_scan_result_dialog_views.h
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.
4
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_
7
8 #include <map>
9
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"
15
16 namespace views {
17 class Checkbox;
18 class ImageButton;
19 class Label;
20 class MenuRunner;
21 class Widget;
22 }
23
24 // The media galleries scan result view for Views. It will immediately show
25 // upon construction.
26 class MediaGalleriesScanResultDialogViews
27     : public MediaGalleriesScanResultDialog,
28       public views::ButtonListener,
29       public views::ContextMenuController,
30       public views::DialogDelegate {
31  public:
32   explicit MediaGalleriesScanResultDialogViews(
33       MediaGalleriesScanResultDialogController* controller);
34   virtual ~MediaGalleriesScanResultDialogViews();
35
36   // MediaGalleriesScanResultDialog implementation:
37   virtual void UpdateResults() OVERRIDE;
38
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;
50
51   // views::ButtonListener implementation:
52   virtual void ButtonPressed(views::Button* sender,
53                              const ui::Event& event) OVERRIDE;
54
55   // views::ContextMenuController implementation:
56   virtual void ShowContextMenuForView(views::View* source,
57                                       const gfx::Point& point,
58                                       ui::MenuSourceType source_type) OVERRIDE;
59
60  private:
61   struct GalleryEntry {
62     views::Checkbox* checkbox;
63     views::ImageButton* folder_viewer_button;
64     views::Label* secondary_text;
65   };
66   typedef std::map<MediaGalleryPrefId, GalleryEntry> GalleryViewMap;
67
68   void InitChildViews();
69
70   // Adds a checkbox or updates an existing checkbox. Returns true if a new one
71   // was added.
72   bool AddOrUpdateScanResult(const MediaGalleryPrefInfo& gallery,
73                              bool selected,
74                              views::View* container,
75                              int trailing_vertical_space);
76
77   void ShowContextMenu(const gfx::Point& point,
78                        ui::MenuSourceType source_type,
79                        MediaGalleryPrefId id);
80
81   MediaGalleriesScanResultDialogController* controller_;
82
83   // The containing window (a weak pointer).
84   views::Widget* window_;
85
86   // The contents of the dialog. Owned by |window_|'s RootView.
87   views::View* contents_;
88
89   // A map from media gallery ID to the view elements for each gallery.
90   GalleryViewMap gallery_view_map_;
91
92   // True if the user has pressed accept.
93   bool accepted_;
94
95   scoped_ptr<views::MenuRunner> context_menu_runner_;
96
97   DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogViews);
98 };
99
100 #endif  // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_VIEWS_H_