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
3 // found in the LICENSE file.
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_
8 #import <Cocoa/Cocoa.h>
9 #import <Quartz/Quartz.h>
11 #include "base/callback.h"
12 #import "base/mac/scoped_nsobject.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "chrome/browser/media/desktop_media_list.h"
16 #include "chrome/browser/media/desktop_media_picker.h"
17 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_bridge.h"
19 // A controller for the Desktop Media Picker. Presents the user with a list of
20 // media sources for screen-capturing, and reports the result.
21 @interface DesktopMediaPickerController
22 : NSWindowController
<NSWindowDelegate
, DesktopMediaPickerObserver
> {
24 // The image browser view to present sources to the user (thumbnails and
26 base::scoped_nsobject
<IKImageBrowserView
> sourceBrowser_
;
28 // The button used to confirm the selection.
29 NSButton
* shareButton_
; // weak; owned by contentView
31 // The button used to cancel and close the dialog.
32 NSButton
* cancelButton_
; // weak; owned by contentView
34 // Provides source information (including thumbnails) to fill up |items_| and
35 // to render in |sourceBrowser_|.
36 scoped_ptr
<DesktopMediaList
> media_list_
;
38 // To be called with the user selection.
39 DesktopMediaPicker::DoneCallback doneCallback_
;
41 // Array of |DesktopMediaPickerItem| used as data for |sourceBrowser_|.
42 base::scoped_nsobject
<NSMutableArray
> items_
;
44 // C++ bridge to use as an observer to |media_list_|, that forwards obj-c
45 // notifications to this object.
46 scoped_ptr
<DesktopMediaPickerBridge
> bridge_
;
48 // Used to create |DesktopMediaPickerItem|s with unique IDs.
52 // Designated initializer.
53 // To show the dialog, use |NSWindowController|'s |showWindow:|.
54 // |callback| will be called to report the user's selection.
55 // |appName| will be used to format the dialog's title and the label, where it
56 // appears as the initiator of the request.
57 // |targetName| will be used to format the dialog's label and appear as the
58 // consumer of the requested stream.
59 - (id
)initWithMediaList
:(scoped_ptr
<DesktopMediaList
>)media_list
60 parent
:(NSWindow
*)parent
61 callback
:(const DesktopMediaPicker::DoneCallback
&)callback
62 appName
:(const base::string16
&)appName
63 targetName
:(const base::string16
&)targetName
;
67 #endif // CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_