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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ 6#define CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ 7 8#import <Cocoa/Cocoa.h> 9 10#include "base/basictypes.h" 11#include "base/memory/scoped_ptr.h" 12#include "ui/web_dialogs/web_dialog_ui.h" 13 14class WebDialogWindowDelegateBridge; 15 16namespace content { 17class BrowserContext; 18class WebContents; 19} 20 21// This controller manages a dialog box with properties and HTML content taken 22// from a WebDialogDelegate object. 23@interface WebDialogWindowController : NSWindowController<NSWindowDelegate> { 24 @private 25 // Order here is important, as webContents_ may send messages to 26 // delegate_ when it gets destroyed. 27 scoped_ptr<WebDialogWindowDelegateBridge> delegate_; 28 scoped_ptr<content::WebContents> webContents_; 29} 30 31// Creates and shows an WebDialogWindowController with the given 32// delegate and profile. The window is automatically destroyed when it, or its 33// profile, is closed. Returns the created window. 34// 35// Make sure to use the returned window only when you know it is safe 36// to do so, i.e. before OnDialogClosed() is called on the delegate. 37+ (NSWindow*)showWebDialog:(ui::WebDialogDelegate*)delegate 38 context:(content::BrowserContext*)context; 39 40@end 41 42@interface WebDialogWindowController (TestingAPI) 43 44// This is the designated initializer. However, this is exposed only 45// for testing; use -showWebDialog:context: instead. 46- (id)initWithDelegate:(ui::WebDialogDelegate*)delegate 47 context:(content::BrowserContext*)context; 48 49// Loads the HTML content from the delegate; this is not a lightweight 50// process which is why it is not part of the constructor. Must be 51// called before -showWebDialog:context:. 52- (void)loadDialogContents; 53 54@end 55 56#endif // CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ 57