Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / media_galleries_dialog_cocoa.h
blob8bccc282dacba3ae2a9e532a7b9abc40c4c961f9
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"
14 @class ConstrainedWindowAlert;
15 @class MediaGalleriesCocoaController;
17 class MediaGalleriesDialogBrowserTest;
18 class MediaGalleriesDialogTest;
20 namespace ui {
21 class MenuModel;
24 // This class displays an alert that can be used to grant permission for
25 // extensions to access a gallery (media folders).
26 class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate,
27 public MediaGalleriesDialog {
28 public:
29 MediaGalleriesDialogCocoa(
30 MediaGalleriesDialogController* controller,
31 MediaGalleriesCocoaController* delegate);
32 virtual ~MediaGalleriesDialogCocoa();
34 // Called when the user clicks the accept button.
35 void OnAcceptClicked();
36 // Called when the user clicks the cancel button.
37 void OnCancelClicked();
38 // Called when the user clicks the Add Gallery button.
39 void OnAddFolderClicked();
40 // Called when the user toggles a gallery checkbox.
41 void OnCheckboxToggled(NSButton* checkbox);
43 // MediaGalleriesDialog implementation:
44 virtual void UpdateGalleries() OVERRIDE;
46 // ConstrainedWindowMacDelegate implementation.
47 virtual void OnConstrainedWindowClosed(
48 ConstrainedWindowMac* window) OVERRIDE;
50 ui::MenuModel* GetContextMenuModel(MediaGalleryPrefId prefid);
52 private:
53 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close);
54 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes);
55 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes);
56 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds);
57 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes);
59 void UpdateGalleryCheckbox(const MediaGalleryPrefInfo& gallery,
60 bool permitted,
61 CGFloat y_pos);
63 void InitDialogControls();
64 CGFloat CreateAddFolderButton();
65 CGFloat CreateAttachedCheckboxes(
66 CGFloat y_pos,
67 const MediaGalleriesDialogController::GalleryPermissionsVector&
68 permissions);
69 CGFloat CreateUnattachedCheckboxes(
70 CGFloat y_pos,
71 const MediaGalleriesDialogController::GalleryPermissionsVector&
72 permissions);
73 CGFloat CreateCheckboxSeparator(CGFloat y_pos);
75 MediaGalleriesDialogController* controller_; // weak
76 scoped_ptr<ConstrainedWindowMac> window_;
78 // The alert that the dialog is being displayed as.
79 base::scoped_nsobject<ConstrainedWindowAlert> alert_;
81 // True if the user has pressed accept.
82 bool accepted_;
84 // List of checkboxes ordered from bottom to top.
85 base::scoped_nsobject<NSMutableArray> checkboxes_;
87 // Container view for checkboxes.
88 base::scoped_nsobject<NSView> checkbox_container_;
90 // Container view for the main dialog contents.
91 base::scoped_nsobject<NSBox> accessory_;
93 // An Objective-C class to route callbacks from Cocoa code.
94 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_;
96 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa);
99 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_