Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / extensions / media_galleries_dialog_gtk.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include <map>
11
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
15 #include "chrome/browser/ui/gtk/constrained_window_gtk.h"
16 #include "ui/base/gtk/gtk_signal.h"
17 #include "ui/gfx/scoped_gobject.h"
18
19 class MediaGalleriesDialogController;
20 class MediaGalleriesDialogTest;
21
22 // The media galleries configuration view for Gtk. It will immediately show
23 // upon construction.
24 class MediaGalleriesDialogGtk : public MediaGalleriesDialog {
25  public:
26   explicit MediaGalleriesDialogGtk(MediaGalleriesDialogController* controller);
27   virtual ~MediaGalleriesDialogGtk();
28
29   // MediaGalleriesDialog implementation:
30   virtual void UpdateGalleries() OVERRIDE;
31
32   // Event callbacks.
33   CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnToggled);
34   CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnAddFolder);
35   CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnConfirm);
36   CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnCancel);
37
38  private:
39   FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes);
40   FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes);
41   FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds);
42   FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes);
43
44   typedef std::map<MediaGalleryPrefId, GtkWidget*> CheckboxMap;
45   typedef std::map<GtkWidget*, MediaGalleryPrefInfo> NewCheckboxMap;
46
47   // Creates the widget hierarchy.
48   void InitWidgets();
49
50   virtual void UpdateGalleryInContainer(const MediaGalleryPrefInfo& gallery,
51                                         bool permitted,
52                                         GtkWidget* checkbox_container);
53
54   // Updates the state of the confirm button. It will be disabled when
55   void UpdateConfirmButtonState();
56
57   CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnDestroy);
58
59   MediaGalleriesDialogController* controller_;
60   GtkWidget* window_;
61
62   // The root widget for the dialog.
63   ui::ScopedGObject<GtkWidget>::Type contents_;
64
65   // The confirm button.
66   GtkWidget* confirm_;
67
68   // A map from MediaGalleryPrefId to the GtkCheckButton that controls it.
69   CheckboxMap checkbox_map_;
70
71   // Map for checkboxes of newly-added galleries to their MediaGalleryPrefInfo.
72   NewCheckboxMap new_checkbox_map_;
73
74   // True if the user has pressed accept.
75   bool accepted_;
76
77   DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogGtk);
78 };
79
80 #endif  // CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_