Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1564)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/media_galleries_scan_result_dialog_cocoa.h

Issue 231873003: Refactor media galleries dialogs on cocoa to extract common code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_SCAN_RESULT_DIALOG_CO COA_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_CO COA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_CO COA_H_ 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_CO COA_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "chrome/browser/media_galleries/media_galleries_scan_result_dialog_cont roller.h" 10 #include "chrome/browser/media_galleries/media_galleries_scan_result_dialog_cont roller.h"
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
12 #import "chrome/browser/ui/cocoa/extensions/media_gallery_list_entry_view.h"
12 13
13 @class ConstrainedWindowAlert; 14 @class ConstrainedWindowAlert;
14 @class MediaGalleriesScanResultCocoaController; 15 @class MediaGalleriesScanResultCocoaController;
15 16
16 17
17 namespace ui { 18 namespace ui {
18 class MenuModel; 19 class MenuModel;
19 } 20 }
20 21
21 // This class displays an alert where the user selects which scan results 22 // This class displays an alert where the user selects which scan results
22 // (media folders) the app (extension) should have access to. 23 // (media folders) the app (extension) should have access to.
23 class MediaGalleriesScanResultDialogCocoa 24 class MediaGalleriesScanResultDialogCocoa
24 : public ConstrainedWindowMacDelegate, 25 : public ConstrainedWindowMacDelegate,
25 public MediaGalleriesScanResultDialog { 26 public MediaGalleriesScanResultDialog,
27 public MediaGalleryListEntryController {
26 public: 28 public:
27 MediaGalleriesScanResultDialogCocoa( 29 MediaGalleriesScanResultDialogCocoa(
28 MediaGalleriesScanResultDialogController* controller, 30 MediaGalleriesScanResultDialogController* controller,
29 MediaGalleriesScanResultCocoaController* delegate); 31 MediaGalleriesScanResultCocoaController* delegate);
30 virtual ~MediaGalleriesScanResultDialogCocoa(); 32 virtual ~MediaGalleriesScanResultDialogCocoa();
31 33
32 // Called when the user clicks the accept button. 34 // Called when the user clicks the accept button.
33 void OnAcceptClicked(); 35 void OnAcceptClicked();
34 // Called when the user clicks the cancel button. 36 // Called when the user clicks the cancel button.
35 void OnCancelClicked(); 37 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 38
41 // MediaGalleriesScanResultDialog implementation: 39 // MediaGalleriesScanResultDialog implementation:
42 virtual void UpdateResults() OVERRIDE; 40 virtual void UpdateResults() OVERRIDE;
43 41
44 // ConstrainedWindowMacDelegate implementation. 42 // ConstrainedWindowMacDelegate implementation.
45 virtual void OnConstrainedWindowClosed( 43 virtual void OnConstrainedWindowClosed(
46 ConstrainedWindowMac* window) OVERRIDE; 44 ConstrainedWindowMac* window) OVERRIDE;
47 45
48 ui::MenuModel* GetContextMenu(MediaGalleryPrefId prefid); 46 // MediaGalleryListEntryController implementation.
47 virtual void OnCheckboxToggled(MediaGalleryPrefId prefId,
48 bool checked) OVERRIDE;
49 virtual void OnFolderViewerClicked(MediaGalleryPrefId prefId) OVERRIDE;
50 virtual ui::MenuModel* GetContextMenu(MediaGalleryPrefId prefid) OVERRIDE;
49 51
50 private: 52 private:
51 friend class MediaGalleriesScanResultDialogCocoaTest; 53 friend class MediaGalleriesScanResultDialogCocoaTest;
52 54
53 void UpdateScanResultCheckbox(const MediaGalleryPrefInfo& scan_result,
54 bool checked,
55 CGFloat y_pos);
56
57 void InitDialogControls(); 55 void InitDialogControls();
58 CGFloat CreateCheckboxes( 56 CGFloat CreateCheckboxes();
59 CGFloat y_pos,
60 const MediaGalleriesScanResultDialogController::OrderedScanResults&
61 scan_results);
62 57
63 // MediaGalleriesScanResultDialog implementation: 58 // MediaGalleriesScanResultDialog implementation:
64 virtual void AcceptDialogForTesting() OVERRIDE; 59 virtual void AcceptDialogForTesting() OVERRIDE;
65 60
66 MediaGalleriesScanResultDialogController* controller_; // weak 61 MediaGalleriesScanResultDialogController* controller_; // weak
67 scoped_ptr<ConstrainedWindowMac> window_; 62 scoped_ptr<ConstrainedWindowMac> window_;
68 63
69 // The alert that the dialog is being displayed as. 64 // The alert that the dialog is being displayed as.
70 base::scoped_nsobject<ConstrainedWindowAlert> alert_; 65 base::scoped_nsobject<ConstrainedWindowAlert> alert_;
71 66
72 // True if the user has pressed accept. 67 // True if the user has pressed accept.
73 bool accepted_; 68 bool accepted_;
74 69
75 // List of checkboxes ordered from bottom to top.
76 base::scoped_nsobject<NSMutableArray> checkboxes_;
77
78 // Container view for checkboxes. 70 // Container view for checkboxes.
79 base::scoped_nsobject<NSView> checkbox_container_; 71 base::scoped_nsobject<NSView> checkbox_container_;
80 72
81 // Container view for the main dialog contents. 73 // Container view for the main dialog contents.
82 base::scoped_nsobject<NSBox> main_container_; 74 base::scoped_nsobject<NSBox> main_container_;
83 75
84 // An Objective-C class to route callbacks from Cocoa code. 76 // An Objective-C class to route callbacks from Cocoa code.
85 base::scoped_nsobject<MediaGalleriesScanResultCocoaController> 77 base::scoped_nsobject<MediaGalleriesScanResultCocoaController>
86 cocoa_controller_; 78 cocoa_controller_;
87 79
88 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogCocoa); 80 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogCocoa);
89 }; 81 };
90 82
91 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG _COCOA_H_ 83 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG _COCOA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698