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 #import "chrome/browser/ui/cocoa/extensions/media_gallery_list_entry_view.h" |
14 | 14 |
15 @class ConstrainedWindowAlert; | 15 @class ConstrainedWindowAlert; |
16 @class MediaGalleriesCocoaController; | 16 @class MediaGalleriesCocoaController; |
| 17 @class NSString; |
17 | 18 |
18 class MediaGalleriesDialogBrowserTest; | 19 class MediaGalleriesDialogBrowserTest; |
19 class MediaGalleriesDialogTest; | 20 class MediaGalleriesDialogTest; |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 class MenuModel; | 23 class MenuModel; |
23 } | 24 } |
24 | 25 |
25 // This class displays an alert that can be used to grant permission for | 26 // This class displays an alert that can be used to manage lists of media |
26 // extensions to access a gallery (media folders). | 27 // galleries. |
27 class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate, | 28 class MediaGalleriesDialogCocoa : public ConstrainedWindowMacDelegate, |
28 public MediaGalleriesDialog, | 29 public MediaGalleriesDialog, |
29 public MediaGalleryListEntryController { | 30 public MediaGalleryListEntryController { |
30 public: | 31 public: |
31 MediaGalleriesDialogCocoa( | 32 MediaGalleriesDialogCocoa( |
32 MediaGalleriesDialogController* controller, | 33 MediaGalleriesDialogController* controller, |
33 MediaGalleriesCocoaController* delegate); | 34 MediaGalleriesCocoaController* delegate); |
34 virtual ~MediaGalleriesDialogCocoa(); | 35 virtual ~MediaGalleriesDialogCocoa(); |
35 | 36 |
36 // Called when the user clicks the accept button. | 37 // Called when the user clicks the accept button. |
37 void OnAcceptClicked(); | 38 void OnAcceptClicked(); |
38 // Called when the user clicks the cancel button. | 39 // Called when the user clicks the cancel button. |
39 void OnCancelClicked(); | 40 void OnCancelClicked(); |
40 // Called when the user clicks the Add Gallery button. | 41 // Called when the user clicks the auxiliary button. |
41 void OnAddFolderClicked(); | 42 void OnAuxilliaryButtonClicked(); |
42 | 43 |
43 // MediaGalleriesDialog implementation: | 44 // MediaGalleriesDialog implementation: |
44 virtual void UpdateGalleries() OVERRIDE; | 45 virtual void UpdateGalleries() OVERRIDE; |
45 | 46 |
46 // ConstrainedWindowMacDelegate implementation. | 47 // ConstrainedWindowMacDelegate implementation. |
47 virtual void OnConstrainedWindowClosed( | 48 virtual void OnConstrainedWindowClosed( |
48 ConstrainedWindowMac* window) OVERRIDE; | 49 ConstrainedWindowMac* window) OVERRIDE; |
49 | 50 |
50 // MediaGalleryListEntryController implementation. | 51 // MediaGalleryListEntryController implementation. |
51 virtual void OnCheckboxToggled(GalleryDialogId gallery_id, | 52 virtual void OnCheckboxToggled(MediaGalleryPrefId pref_id, |
52 bool checked) OVERRIDE; | 53 bool checked) OVERRIDE; |
53 virtual ui::MenuModel* GetContextMenu(GalleryDialogId gallery_id) OVERRIDE; | 54 virtual void OnFolderViewerClicked(MediaGalleryPrefId prefId) OVERRIDE; |
| 55 virtual ui::MenuModel* GetContextMenu(MediaGalleryPrefId pref_id) OVERRIDE; |
54 | 56 |
55 private: | 57 private: |
56 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close); | 58 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogBrowserTest, Close); |
57 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); | 59 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); |
58 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); | 60 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); |
59 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); | 61 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); |
60 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); | 62 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); |
61 | 63 |
62 void UpdateGalleryCheckbox( | |
63 const MediaGalleriesDialogController::GalleryPermission& gallery, | |
64 CGFloat y_pos); | |
65 | |
66 void InitDialogControls(); | 64 void InitDialogControls(); |
67 CGFloat CreateAddFolderButton(); | |
68 CGFloat CreateCheckboxes( | 65 CGFloat CreateCheckboxes( |
69 CGFloat y_pos, | 66 CGFloat y_pos, |
70 const MediaGalleriesDialogController::GalleryPermissionsVector& | 67 const MediaGalleriesDialogController::Entries& entries); |
71 permissions); | 68 CGFloat CreateCheckboxSeparator(CGFloat y_pos, NSString* header); |
72 CGFloat CreateCheckboxSeparator(CGFloat y_pos); | |
73 | 69 |
74 MediaGalleriesDialogController* controller_; // weak | 70 MediaGalleriesDialogController* controller_; // weak |
75 scoped_ptr<ConstrainedWindowMac> window_; | 71 scoped_ptr<ConstrainedWindowMac> window_; |
76 | 72 |
77 // The alert that the dialog is being displayed as. | 73 // The alert that the dialog is being displayed as. |
78 base::scoped_nsobject<ConstrainedWindowAlert> alert_; | 74 base::scoped_nsobject<ConstrainedWindowAlert> alert_; |
79 | 75 |
80 // True if the user has pressed accept. | 76 // True if the user has pressed accept. |
81 bool accepted_; | 77 bool accepted_; |
82 | 78 |
83 // Container view for checkboxes. | 79 // Container view for checkboxes. |
84 base::scoped_nsobject<NSView> checkbox_container_; | 80 base::scoped_nsobject<NSView> checkbox_container_; |
85 | 81 |
86 // Container view for the main dialog contents. | 82 // Container view for the main dialog contents. |
87 base::scoped_nsobject<NSBox> main_container_; | 83 base::scoped_nsobject<NSBox> main_container_; |
88 | 84 |
89 // An Objective-C class to route callbacks from Cocoa code. | 85 // An Objective-C class to route callbacks from Cocoa code. |
90 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; | 86 base::scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; |
91 | 87 |
92 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); | 88 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); |
93 }; | 89 }; |
94 | 90 |
95 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ | 91 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ |
OLD | NEW |