| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #import <Quartz/Quartz.h> | 9 #import <Quartz/Quartz.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #import "base/mac/scoped_nsobject.h" | 14 #import "base/mac/scoped_nsobject.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "chrome/browser/media/desktop_media_list.h" | 16 #include "chrome/browser/media/desktop_media_list.h" |
| 17 #include "chrome/browser/media/desktop_media_picker.h" | 17 #include "chrome/browser/media/desktop_media_picker.h" |
| 18 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_bridge.h" | 18 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_bridge.h" |
| 19 | 19 |
| 20 // A controller for the Desktop Media Picker. Presents the user with a list of | 20 // A controller for the Desktop Media Picker. Presents the user with a list of |
| 21 // media sources for screen-capturing, and reports the result. | 21 // media sources for screen-capturing, and reports the result. |
| 22 @interface DesktopMediaPickerController | 22 @interface DesktopMediaPickerController |
| 23 : NSWindowController<NSWindowDelegate, DesktopMediaPickerObserver> { | 23 : NSWindowController<NSWindowDelegate, |
| 24 DesktopMediaPickerObserver, |
| 25 NSTableViewDataSource, |
| 26 NSTableViewDelegate> { |
| 24 @private | 27 @private |
| 25 // The image browser view to present sources to the user (thumbnails and | 28 // The image browser view or table view to present sources to the user |
| 26 // names). | 29 // (thumbnails and names). |
| 27 base::scoped_nsobject<IKImageBrowserView> sourceBrowser_; | 30 base::scoped_nsobject<IKImageBrowserView> screenBrowser_; |
| 31 base::scoped_nsobject<IKImageBrowserView> windowBrowser_; |
| 32 base::scoped_nsobject<NSTableView> tabBrowser_; |
| 33 |
| 34 base::scoped_nsobject<NSScrollView> imageBrowserScroll_; |
| 35 |
| 36 base::scoped_nsobject<NSSegmentedControl> sourceTypeControl_; |
| 28 | 37 |
| 29 // The button used to confirm the selection. | 38 // The button used to confirm the selection. |
| 30 NSButton* shareButton_; // weak; owned by contentView | 39 NSButton* shareButton_; // weak; owned by contentView |
| 31 | 40 |
| 32 // The button used to cancel and close the dialog. | 41 // The button used to cancel and close the dialog. |
| 33 NSButton* cancelButton_; // weak; owned by contentView | 42 NSButton* cancelButton_; // weak; owned by contentView |
| 34 | 43 |
| 35 // The checkbox for audio share. | 44 // The checkbox for audio share. |
| 36 // |audioShareState_| records the state when check box is disabled. | |
| 37 base::scoped_nsobject<NSButton> audioShareCheckbox_; | 45 base::scoped_nsobject<NSButton> audioShareCheckbox_; |
| 38 NSCellStateValue audioShareState_; | |
| 39 | 46 |
| 40 // Provides source information (including thumbnails) to fill up |items_| and | 47 // Provides source information (including thumbnails) to fill up the array of |
| 41 // to render in |sourceBrowser_|. | 48 // |screenItems_|, |windowItems_| and |tabItems_|, and to render in |
| 42 std::unique_ptr<DesktopMediaList> media_list_; | 49 // |screenBrowser_|, |windowBrowser_| and |tabBrowser_|. |
| 50 std::unique_ptr<DesktopMediaList> screenList_; |
| 51 std::unique_ptr<DesktopMediaList> windowList_; |
| 52 std::unique_ptr<DesktopMediaList> tabList_; |
| 43 | 53 |
| 44 // To be called with the user selection. | 54 // To be called with the user selection. |
| 45 DesktopMediaPicker::DoneCallback doneCallback_; | 55 DesktopMediaPicker::DoneCallback doneCallback_; |
| 46 | 56 |
| 47 // Array of |DesktopMediaPickerItem| used as data for |sourceBrowser_|. | 57 // Arrays of |DesktopMediaPickerItem| used as data for |screenBrowser_|, |
| 48 base::scoped_nsobject<NSMutableArray> items_; | 58 // |windowBrowser_| and |tabBrowser_|. |
| 59 base::scoped_nsobject<NSMutableArray> screenItems_; |
| 60 base::scoped_nsobject<NSMutableArray> windowItems_; |
| 61 base::scoped_nsobject<NSMutableArray> tabItems_; |
| 49 | 62 |
| 50 // C++ bridge to use as an observer to |media_list_|, that forwards obj-c | 63 // C++ bridge to use as an observer to |screenList_|, |windowList_| and |
| 51 // notifications to this object. | 64 // |tabList_|, that forwards obj-c notifications to this object. |
| 52 std::unique_ptr<DesktopMediaPickerBridge> bridge_; | 65 std::unique_ptr<DesktopMediaPickerBridge> bridge_; |
| 53 | 66 |
| 54 // Used to create |DesktopMediaPickerItem|s with unique IDs. | 67 // Used to create |DesktopMediaPickerItem|s with unique IDs. |
| 55 int lastImageUID_; | 68 int lastImageUID_; |
| 56 } | 69 } |
| 57 | 70 |
| 58 // Designated initializer. | 71 // Designated initializer. |
| 59 // To show the dialog, use |NSWindowController|'s |showWindow:|. | 72 // To show the dialog, use |NSWindowController|'s |showWindow:|. |
| 60 // |callback| will be called to report the user's selection. | 73 // |callback| will be called to report the user's selection. |
| 61 // |appName| will be used to format the dialog's title and the label, where it | 74 // |appName| will be used to format the dialog's title and the label, where it |
| 62 // appears as the initiator of the request. | 75 // appears as the initiator of the request. |
| 63 // |targetName| will be used to format the dialog's label and appear as the | 76 // |targetName| will be used to format the dialog's label and appear as the |
| 64 // consumer of the requested stream. | 77 // consumer of the requested stream. |
| 65 - (id)initWithScreenList:(std::unique_ptr<DesktopMediaList>)screen_list | 78 - (id)initWithScreenList:(std::unique_ptr<DesktopMediaList>)screenList |
| 66 windowList:(std::unique_ptr<DesktopMediaList>)window_list | 79 windowList:(std::unique_ptr<DesktopMediaList>)windowList |
| 67 tabList:(std::unique_ptr<DesktopMediaList>)tab_list | 80 tabList:(std::unique_ptr<DesktopMediaList>)tabList |
| 68 parent:(NSWindow*)parent | 81 parent:(NSWindow*)parent |
| 69 callback:(const DesktopMediaPicker::DoneCallback&)callback | 82 callback:(const DesktopMediaPicker::DoneCallback&)callback |
| 70 appName:(const base::string16&)appName | 83 appName:(const base::string16&)appName |
| 71 targetName:(const base::string16&)targetName | 84 targetName:(const base::string16&)targetName |
| 72 requestAudio:(bool)requestAudio; | 85 requestAudio:(bool)requestAudio; |
| 73 | 86 |
| 74 @end | 87 @end |
| 75 | 88 |
| 76 #endif // CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_
H_ | 89 #endif // CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_
H_ |
| OLD | NEW |