Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / extensions / media_galleries_scan_result_dialog_cocoa.h
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.
4
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_
7
8 #import <Cocoa/Cocoa.h>
9
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"
12
13 @class ConstrainedWindowAlert;
14 @class MediaGalleriesScanResultCocoaController;
15
16
17 namespace ui {
18 class MenuModel;
19 }
20
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();
31
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);
40
41   // MediaGalleriesScanResultDialog implementation:
42   virtual void UpdateResults() OVERRIDE;
43
44   // ConstrainedWindowMacDelegate implementation.
45   virtual void OnConstrainedWindowClosed(
46       ConstrainedWindowMac* window) OVERRIDE;
47
48   ui::MenuModel* GetContextMenu(MediaGalleryPrefId prefid);
49
50  private:
51   friend class MediaGalleriesScanResultDialogCocoaTest;
52
53   void UpdateScanResultCheckbox(const MediaGalleryPrefInfo& scan_result,
54                                 bool checked,
55                                 CGFloat y_pos);
56
57   void InitDialogControls();
58   CGFloat CreateCheckboxes(
59       CGFloat y_pos,
60       const MediaGalleriesScanResultDialogController::OrderedScanResults&
61           scan_results);
62
63   MediaGalleriesScanResultDialogController* controller_;  // weak
64   scoped_ptr<ConstrainedWindowMac> window_;
65
66   // The alert that the dialog is being displayed as.
67   base::scoped_nsobject<ConstrainedWindowAlert> alert_;
68
69   // True if the user has pressed accept.
70   bool accepted_;
71
72   // List of checkboxes ordered from bottom to top.
73   base::scoped_nsobject<NSMutableArray> checkboxes_;
74
75   // Container view for checkboxes.
76   base::scoped_nsobject<NSView> checkbox_container_;
77
78   // Container view for the main dialog contents.
79   base::scoped_nsobject<NSBox> main_container_;
80
81   // An Objective-C class to route callbacks from Cocoa code.
82   base::scoped_nsobject<MediaGalleriesScanResultCocoaController>
83       cocoa_controller_;
84
85   DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogCocoa);
86 };
87
88 #endif  // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_COCOA_H_