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
;
19 class MediaGalleriesDialogBrowserTest
;
20 class MediaGalleriesDialogTest
;
26 // This class displays an alert that can be used to manage lists of media
28 class MediaGalleriesDialogCocoa
: public ConstrainedWindowMacDelegate
,
29 public MediaGalleriesDialog
,
30 public MediaGalleryListEntryController
{
32 MediaGalleriesDialogCocoa(
33 MediaGalleriesDialogController
* controller
,
34 MediaGalleriesCocoaController
* delegate
);
35 ~MediaGalleriesDialogCocoa() override
;
37 // Called when the user clicks the accept button.
38 void OnAcceptClicked();
39 // Called when the user clicks the cancel button.
40 void OnCancelClicked();
41 // Called when the user clicks the auxiliary button.
42 void OnAuxiliaryButtonClicked();
44 // MediaGalleriesDialog implementation:
45 void UpdateGalleries() override
;
47 // ConstrainedWindowMacDelegate implementation.
48 void OnConstrainedWindowClosed(ConstrainedWindowMac
* window
) override
;
50 // MediaGalleryListEntryController implementation.
51 void OnCheckboxToggled(MediaGalleryPrefId pref_id
, bool checked
) override
;
52 void OnFolderViewerClicked(MediaGalleryPrefId prefId
) override
;
53 ui::MenuModel
* GetContextMenu(MediaGalleryPrefId pref_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 // MediaGalleriesDialog implementation:
63 void AcceptDialogForTesting() override
;
65 void InitDialogControls();
66 CGFloat
CreateCheckboxes(
68 const MediaGalleriesDialogController::Entries
& entries
);
69 CGFloat
CreateCheckboxSeparator(CGFloat y_pos
, NSString
* header
);
71 MediaGalleriesDialogController
* controller_
; // weak
72 scoped_ptr
<ConstrainedWindowMac
> window_
;
74 // The alert that the dialog is being displayed as.
75 base::scoped_nsobject
<ConstrainedWindowAlert
> alert_
;
77 // True if the user has pressed accept.
80 // Container view for checkboxes.
81 base::scoped_nsobject
<NSView
> checkbox_container_
;
83 // Container view for the main dialog contents.
84 base::scoped_nsobject
<NSBox
> main_container_
;
86 // An Objective-C class to route callbacks from Cocoa code.
87 base::scoped_nsobject
<MediaGalleriesCocoaController
> cocoa_controller_
;
89 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa
);
92 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_