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.
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/gtest_prod_util.h"
11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
13 #import "chrome/browser/ui/cocoa/extensions/media_gallery_list_entry_view.h"
15 @
class ConstrainedWindowAlert
;
16 @
class MediaGalleriesCocoaController
;
18 class MediaGalleriesDialogBrowserTest
;
19 class MediaGalleriesDialogTest
;
25 // This class displays an alert that can be used to grant permission for
26 // extensions to access a gallery (media folders).
27 class MediaGalleriesDialogCocoa
: public ConstrainedWindowMacDelegate
,
28 public MediaGalleriesDialog
,
29 public MediaGalleryListEntryController
{
31 MediaGalleriesDialogCocoa(
32 MediaGalleriesDialogController
* controller
,
33 MediaGalleriesCocoaController
* delegate
);
34 virtual ~MediaGalleriesDialogCocoa();
36 // Called when the user clicks the accept button.
37 void OnAcceptClicked();
38 // Called when the user clicks the cancel button.
39 void OnCancelClicked();
40 // Called when the user clicks the Add Gallery button.
41 void OnAddFolderClicked();
43 // MediaGalleriesDialog implementation:
44 virtual void UpdateGalleries() OVERRIDE
;
46 // ConstrainedWindowMacDelegate implementation.
47 virtual void OnConstrainedWindowClosed(
48 ConstrainedWindowMac
* window
) OVERRIDE
;
50 // MediaGalleryListEntryController implementation.
51 virtual void OnCheckboxToggled(GalleryDialogId gallery_id
,
52 bool checked
) OVERRIDE
;
53 virtual ui::MenuModel
* GetContextMenu(GalleryDialogId gallery_id
) OVERRIDE
;
56 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest
, Close
);
57 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest
, InitializeCheckboxes
);
58 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest
, ToggleCheckboxes
);
59 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest
, UpdateAdds
);
60 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest
, ForgetDeletes
);
62 void UpdateGalleryCheckbox(
63 const MediaGalleriesDialogController::GalleryPermission
& gallery
,
66 void InitDialogControls();
67 CGFloat
CreateAddFolderButton();
68 CGFloat
CreateCheckboxes(
70 const MediaGalleriesDialogController::GalleryPermissionsVector
&
72 CGFloat
CreateCheckboxSeparator(CGFloat y_pos
);
74 MediaGalleriesDialogController
* controller_
; // weak
75 scoped_ptr
<ConstrainedWindowMac
> window_
;
77 // The alert that the dialog is being displayed as.
78 base::scoped_nsobject
<ConstrainedWindowAlert
> alert_
;
80 // True if the user has pressed accept.
83 // Container view for checkboxes.
84 base::scoped_nsobject
<NSView
> checkbox_container_
;
86 // Container view for the main dialog contents.
87 base::scoped_nsobject
<NSBox
> main_container_
;
89 // An Objective-C class to route callbacks from Cocoa code.
90 base::scoped_nsobject
<MediaGalleriesCocoaController
> cocoa_controller_
;
92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa
);
95 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_