| 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 "chrome/browser/media_gallery/media_galleries_dialog_controller.h" | 11 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h" |
| 11 #import "chrome/browser/ui/cocoa/constrained_window_mac.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 12 | 13 |
| 13 @class MediaGalleriesCocoaController; | 14 @class MediaGalleriesCocoaController; |
| 14 | 15 |
| 15 namespace chrome { | 16 namespace chrome { |
| 16 | 17 |
| 18 class MediaGalleriesDialogTest; |
| 19 |
| 17 // This class displays an alert that can be used to grant permission for | 20 // This class displays an alert that can be used to grant permission for |
| 18 // extensions to access a gallery (media folders). | 21 // extensions to access a gallery (media folders). |
| 19 class MediaGalleriesDialogCocoa : | 22 class MediaGalleriesDialogCocoa : |
| 20 public ConstrainedWindowMacDelegateSystemSheet, | 23 public ConstrainedWindowMacDelegateSystemSheet, |
| 21 public MediaGalleriesDialog { | 24 public MediaGalleriesDialog { |
| 22 public: | 25 public: |
| 23 MediaGalleriesDialogCocoa( | 26 MediaGalleriesDialogCocoa( |
| 24 MediaGalleriesDialogController* controller, | 27 MediaGalleriesDialogController* controller, |
| 25 MediaGalleriesCocoaController* delegate); | 28 MediaGalleriesCocoaController* delegate); |
| 26 virtual ~MediaGalleriesDialogCocoa(); | 29 virtual ~MediaGalleriesDialogCocoa(); |
| 27 | 30 |
| 28 // Called when the user clicks the Add Gallery button. | 31 // Called when the user clicks the Add Gallery button. |
| 29 void OnAddFolderClicked(); | 32 void OnAddFolderClicked(); |
| 30 // Called when the user toggles a gallery checkbox. | 33 // Called when the user toggles a gallery checkbox. |
| 31 void OnCheckboxToggled(NSButton* checkbox); | 34 void OnCheckboxToggled(NSButton* checkbox); |
| 32 // Called when the alert closes. | 35 // Called when the alert closes. |
| 33 void SheetDidEnd(NSInteger result); | 36 void SheetDidEnd(NSInteger result); |
| 34 | 37 |
| 35 // MediaGalleriesDialog implementation: | 38 // MediaGalleriesDialog implementation: |
| 36 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, | 39 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, |
| 37 bool permitted) OVERRIDE; | 40 bool permitted) OVERRIDE; |
| 38 | 41 |
| 39 // ConstrainedWindowMacDelegateSystemSheet implementation. | 42 // ConstrainedWindowMacDelegateSystemSheet implementation. |
| 40 virtual void DeleteDelegate() OVERRIDE; | 43 virtual void DeleteDelegate() OVERRIDE; |
| 41 | 44 |
| 42 private: | 45 private: |
| 46 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); |
| 47 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); |
| 48 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); |
| 49 |
| 43 void UpdateGalleryCheckbox(NSButton* checkbox, | 50 void UpdateGalleryCheckbox(NSButton* checkbox, |
| 44 const MediaGalleryPrefInfo* gallery, | 51 const MediaGalleryPrefInfo* gallery, |
| 45 bool permitted); | 52 bool permitted); |
| 46 void UpdateCheckboxContainerFrame(); | 53 void UpdateCheckboxContainerFrame(); |
| 47 | 54 |
| 48 MediaGalleriesDialogController* controller_; // weak | 55 MediaGalleriesDialogController* controller_; // weak |
| 49 ConstrainedWindow* window_; // weak | 56 ConstrainedWindow* window_; // weak |
| 50 | 57 |
| 51 // True if the user has pressed accept. | 58 // True if the user has pressed accept. |
| 52 bool accepted_; | 59 bool accepted_; |
| 53 | 60 |
| 54 // List of checkboxes ordered from bottom to top. | 61 // List of checkboxes ordered from bottom to top. |
| 55 scoped_nsobject<NSMutableArray> checkboxes_; | 62 scoped_nsobject<NSMutableArray> checkboxes_; |
| 56 | 63 |
| 57 // Container view for checkboxes. | 64 // Container view for checkboxes. |
| 58 scoped_nsobject<NSView> checkbox_container_; | 65 scoped_nsobject<NSView> checkbox_container_; |
| 59 | 66 |
| 60 // The alert that the dialog is being displayed as. | 67 // The alert that the dialog is being displayed as. |
| 61 scoped_nsobject<NSAlert> alert_; | 68 scoped_nsobject<NSAlert> alert_; |
| 62 | 69 |
| 63 // An Objective-C class to route callbacks from Cocoa code. | 70 // An Objective-C class to route callbacks from Cocoa code. |
| 64 scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; | 71 scoped_nsobject<MediaGalleriesCocoaController> cocoa_controller_; |
| 65 | 72 |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); | 73 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogCocoa); |
| 67 }; | 74 }; |
| 68 | 75 |
| 69 } // namespace chrome | 76 } // namespace chrome |
| 70 | 77 |
| 71 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ | 78 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_DIALOG_COCOA_H_ |
| OLD | NEW |