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_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_COCOA_H_
8 #import <Cocoa/Cocoa.h>
10 #include "chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.h"
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
13 @class ConstrainedWindowAlert;
14 @class MediaGalleriesScanResultCocoaController;
21 // This class displays an alert where the user selects which scan results
22 // (media folders) the app (extension) should have access to.
23 class MediaGalleriesScanResultDialogCocoa
24 : public ConstrainedWindowMacDelegate,
25 public MediaGalleriesScanResultDialog {
27 MediaGalleriesScanResultDialogCocoa(
28 MediaGalleriesScanResultDialogController* controller,
29 MediaGalleriesScanResultCocoaController* delegate);
30 virtual ~MediaGalleriesScanResultDialogCocoa();
32 // Called when the user clicks the accept button.
33 void OnAcceptClicked();
34 // Called when the user clicks the cancel button.
35 void OnCancelClicked();
36 // Called when the user toggles a gallery checkbox.
37 void OnCheckboxToggled(NSButton* checkbox);
38 // Called when the user toggles a gallery checkbox.
39 void OnFolderViewClicked(NSButton* folder_viewer_button);
41 // MediaGalleriesScanResultDialog implementation:
42 virtual void UpdateResults() OVERRIDE;
44 // ConstrainedWindowMacDelegate implementation.
45 virtual void OnConstrainedWindowClosed(
46 ConstrainedWindowMac* window) OVERRIDE;
48 ui::MenuModel* GetContextMenu(MediaGalleryPrefId prefid);
51 friend class MediaGalleriesScanResultDialogCocoaTest;
53 void UpdateScanResultCheckbox(const MediaGalleryPrefInfo& scan_result,
57 void InitDialogControls();
58 CGFloat CreateCheckboxes(
60 const MediaGalleriesScanResultDialogController::OrderedScanResults&
63 MediaGalleriesScanResultDialogController* controller_; // weak
64 scoped_ptr<ConstrainedWindowMac> window_;
66 // The alert that the dialog is being displayed as.
67 base::scoped_nsobject<ConstrainedWindowAlert> alert_;
69 // True if the user has pressed accept.
72 // List of checkboxes ordered from bottom to top.
73 base::scoped_nsobject<NSMutableArray> checkboxes_;
75 // Container view for checkboxes.
76 base::scoped_nsobject<NSView> checkbox_container_;
78 // Container view for the main dialog contents.
79 base::scoped_nsobject<NSBox> main_container_;
81 // An Objective-C class to route callbacks from Cocoa code.
82 base::scoped_nsobject<MediaGalleriesScanResultCocoaController>
85 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogCocoa);
88 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_COCOA_H_