Add unit test for the Settings API Bubble.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / media_galleries_scan_result_dialog_cocoa.h
blob142f4110bbc456a0b4b16ab5b21c5ccbc39b5f61
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;
17 namespace ui {
18 class MenuModel;
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 {
26 public:
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);
50 private:
51 friend class MediaGalleriesScanResultDialogCocoaTest;
53 void UpdateScanResultCheckbox(const MediaGalleryPrefInfo& scan_result,
54 bool checked,
55 CGFloat y_pos);
57 void InitDialogControls();
58 CGFloat CreateCheckboxes(
59 CGFloat y_pos,
60 const MediaGalleriesScanResultDialogController::OrderedScanResults&
61 scan_results);
63 // MediaGalleriesScanResultDialog implementation:
64 virtual void AcceptDialogForTesting() OVERRIDE;
66 MediaGalleriesScanResultDialogController* controller_; // weak
67 scoped_ptr<ConstrainedWindowMac> window_;
69 // The alert that the dialog is being displayed as.
70 base::scoped_nsobject<ConstrainedWindowAlert> alert_;
72 // True if the user has pressed accept.
73 bool accepted_;
75 // List of checkboxes ordered from bottom to top.
76 base::scoped_nsobject<NSMutableArray> checkboxes_;
78 // Container view for checkboxes.
79 base::scoped_nsobject<NSView> checkbox_container_;
81 // Container view for the main dialog contents.
82 base::scoped_nsobject<NSBox> main_container_;
84 // An Objective-C class to route callbacks from Cocoa code.
85 base::scoped_nsobject<MediaGalleriesScanResultCocoaController>
86 cocoa_controller_;
88 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogCocoa);
91 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_COCOA_H_