158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// found in the LICENSE file. 458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ 658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ 758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#import <Cocoa/Cocoa.h> 958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#import <Quartz/Quartz.h> 1058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/callback.h" 1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#import "base/mac/scoped_nsobject.h" 1358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 1458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/strings/string16.h" 15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/media/desktop_media_list.h" 1658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/media/desktop_media_picker.h" 1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_bridge.h" 1858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 1958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// A controller for the Desktop Media Picker. Presents the user with a list of 2058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// media sources for screen-capturing, and reports the result. 2158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)@interface DesktopMediaPickerController 2258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) : NSWindowController<NSWindowDelegate, DesktopMediaPickerObserver> { 2358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) @private 2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The image browser view to present sources to the user (thumbnails and 2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // names). 2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) base::scoped_nsobject<IKImageBrowserView> sourceBrowser_; 2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 2858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The button used to confirm the selection. 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NSButton* shareButton_; // weak; owned by contentView 3058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 3158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The button used to cancel and close the dialog. 3258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) NSButton* cancelButton_; // weak; owned by contentView 3358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 3458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Provides source information (including thumbnails) to fill up |items_| and 3558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // to render in |sourceBrowser_|. 36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<DesktopMediaList> media_list_; 3758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 3858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // To be called with the user selection. 3958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) DesktopMediaPicker::DoneCallback doneCallback_; 4058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 4158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Array of |DesktopMediaPickerItem| used as data for |sourceBrowser_|. 4258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) base::scoped_nsobject<NSMutableArray> items_; 4358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // C++ bridge to use as an observer to |media_list_|, that forwards obj-c 4558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // notifications to this object. 4658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) scoped_ptr<DesktopMediaPickerBridge> bridge_; 4758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 4858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Used to create |DesktopMediaPickerItem|s with unique IDs. 4958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int lastImageUID_; 5058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} 5158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 5258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Designated initializer. 5358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// To show the dialog, use |NSWindowController|'s |showWindow:|. 5458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// |callback| will be called to report the user's selection. 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// |appName| will be used to format the dialog's title and the label, where it 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// appears as the initiator of the request. 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// |targetName| will be used to format the dialog's label and appear as the 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// consumer of the requested stream. 59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (id)initWithMediaList:(scoped_ptr<DesktopMediaList>)media_list 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) parent:(NSWindow*)parent 61a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) callback:(const DesktopMediaPicker::DoneCallback&)callback 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) appName:(const base::string16&)appName 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) targetName:(const base::string16&)targetName; 6458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 6558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)@end 6658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 6758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // CHROME_BROWSER_UI_COCOA_MEDIA_PICKER_DESKTOP_MEDIA_PICKER_CONTROLLER_H_ 68