OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 11 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.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" |
13 | 14 |
14 @class ConstrainedWindowAlert; | 15 @class ConstrainedWindowAlert; |
15 @class MediaGalleriesCocoaController; | 16 @class MediaGalleriesCocoaController; |
16 | 17 |
17 class MediaGalleriesDialogBrowserTest; | 18 class MediaGalleriesDialogBrowserTest; |
18 class MediaGalleriesDialogTest; | 19 class MediaGalleriesDialogTest; |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
21 class MenuModel; | 22 class MenuModel; |
22 } | 23 } |
23 | 24 |
24 // This class displays an alert that can be used to grant permission for | 25 // This class displays an alert that can be used to grant permission for |
25 // extensions to access a gallery (media folders). | 26 // extensions to access a gallery (media folders). |
26 class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate, | 27 class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate, |
27 public MediaGalleriesDialog { | 28 public MediaGalleriesDialog, |
| 29 public MediaGalleryListEntryController { |
28 public: | 30 public: |
29 MediaGalleriesDialogCocoa( | 31 MediaGalleriesDialogCocoa( |
30 MediaGalleriesDialogController* controller, | 32 MediaGalleriesDialogController* controller, |
31 MediaGalleriesCocoaController* delegate); | 33 MediaGalleriesCocoaController* delegate); |
32 virtual ~MediaGalleriesDialogCocoa(); | 34 virtual ~MediaGalleriesDialogCocoa(); |
33 | 35 |
34 // Called when the user clicks the accept button. | 36 // Called when the user clicks the accept button. |
35 void OnAcceptClicked(); | 37 void OnAcceptClicked(); |
36 // Called when the user clicks the cancel button. | 38 // Called when the user clicks the cancel button. |
37 void OnCancelClicked(); | 39 void OnCancelClicked(); |
38 // Called when the user clicks the Add Gallery button. | 40 // Called when the user clicks the Add Gallery button. |
39 void OnAddFolderClicked(); | 41 void OnAddFolderClicked(); |
40 // Called when the user toggles a gallery checkbox. | |
41 void OnCheckboxToggled(NSButton* checkbox); | |
42 | 42 |
43 // MediaGalleriesDialog implementation: | 43 // MediaGalleriesDialog implementation: |
44 virtual void UpdateGalleries() OVERRIDE; | 44 virtual void UpdateGalleries() OVERRIDE; |
45 | 45 |
46 // ConstrainedWindowMacDelegate implementation. | 46 // ConstrainedWindowMacDelegate implementation. |
47 virtual void OnConstrainedWindowClosed( | 47 virtual void OnConstrainedWindowClosed( |
48 ConstrainedWindowMac* window) OVERRIDE; | 48 ConstrainedWindowMac* window) OVERRIDE; |
49 | 49 |
50 ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id); | 50 // MediaGalleryListEntryController implementation. |
| 51 virtual void OnCheckboxToggled(GalleryDialogId gallery_id, |
| 52 bool checked) OVERRIDE; |
| 53 virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) OVERRIDE; |
51 | 54 |
52 private: | 55 private: |
53 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close); | 56 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close); |
54 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); | 57 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); |
55 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); | 58 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); |
56 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); | 59 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); |
57 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); | 60 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); |
58 | 61 |
59 void UpdateGalleryCheckbox( | 62 void UpdateGalleryCheckbox( |
60 const MediaGalleriesDialogController::GalleryPermission& gallery, | 63 const MediaGalleriesDialogController::GalleryPermission& gallery, |
61 CGFloat y_pos); | 64 CGFloat y_pos); |
62 | 65 |
63 void InitDialogControls(); | 66 void InitDialogControls(); |
64 CGFloat CreateAddFolderButton(); | 67 CGFloat CreateAddFolderButton(); |
65 CGFloat CreateCheckboxes( | 68 CGFloat CreateCheckboxes( |
66 CGFloat y_pos, | 69 CGFloat y_pos, |
67 const MediaGalleriesDialogController::GalleryPermissionsVector& | 70 const MediaGalleriesDialogController::GalleryPermissionsVector& |
68 permissions); | 71 permissions); |
69 CGFloat CreateCheckboxSeparator(CGFloat y_pos); | 72 CGFloat CreateCheckboxSeparator(CGFloat y_pos); |
70 | 73 |
71 MediaGalleriesDialogController* controller_; // weak | 74 MediaGalleriesDialogController* controller_; // weak |
72 scoped_ptr<ConstrainedWindowMac> window_; | 75 scoped_ptr<ConstrainedWindowMac> window_; |
73 | 76 |
74 // The alert that the dialog is being displayed as. | 77 // The alert that the dialog is being displayed as. |
75 base::scoped_nsobject<ConstrainedWindowAlert> alert_; | 78 base::scoped_nsobject<ConstrainedWindowAlert> alert_; |
76 | 79 |
77 // True if the user has pressed accept. | 80 // True if the user has pressed accept. |
78 bool accepted_; | 81 bool accepted_; |
79 | 82 |
80 // List of checkboxes ordered from bottom to top. | |
81 base::scoped_nsobject<NSMutableArray> checkboxes_; | |
82 | |
83 // Container view for checkboxes. | 83 // Container view for checkboxes. |
84 base::scoped_nsobject<NSView> checkbox_container_; | 84 base::scoped_nsobject<NSView> checkbox_container_; |
85 | 85 |
86 // Container view for the main dialog contents. | 86 // Container view for the main dialog contents. |
87 base::scoped_nsobject<NSBox> main_container_; | 87 base::scoped_nsobject<NSBox> main_container_; |
88 | 88 |
89 // An Objective-C class to route callbacks from Cocoa code. | 89 // An Objective-C class to route callbacks from Cocoa code. |
90 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; | 90 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); | 92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); |
93 }; | 93 }; |
94 | 94 |
95 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ | 95 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ |
OLD | NEW |