html_dialog_window_controller.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
1// Copyright (c) 2011 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_HTML_DIALOG_WINDOW_CONTROLLER_H_
6#define CHROME_BROWSER_UI_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_H_
7#pragma once
8
9#import <Cocoa/Cocoa.h>
10
11#include "base/basictypes.h"
12#include "base/memory/scoped_ptr.h"
13#include "chrome/browser/ui/webui/html_dialog_ui.h"
14
15class HtmlDialogWindowDelegateBridge;
16class Profile;
17class TabContents;
18
19// This controller manages a dialog box with properties and HTML content taken
20// from a HTMLDialogUIDelegate object.
21@interface HtmlDialogWindowController : NSWindowController {
22 @private
23  // Order here is important, as tab_contents_ may send messages to
24  // delegate_ when it gets destroyed.
25  scoped_ptr<HtmlDialogWindowDelegateBridge> delegate_;
26  scoped_ptr<TabContents> tabContents_;
27}
28
29// Creates and shows an HtmlDialogWindowController with the given
30// delegate and profile.  The window is automatically destroyed when
31// it is closed.  Returns the created window.
32//
33// Make sure to use the returned window only when you know it is safe
34// to do so, i.e. before OnDialogClosed() is called on the delegate.
35+ (NSWindow*)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
36                    profile:(Profile*)profile;
37
38@end
39
40@interface HtmlDialogWindowController (TestingAPI)
41
42// This is the designated initializer.  However, this is exposed only
43// for testing; use showHtmlDialog instead.
44- (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate
45               profile:(Profile*)profile;
46
47// Loads the HTML content from the delegate; this is not a lightweight
48// process which is why it is not part of the constructor.  Must be
49// called before showWindow.
50- (void)loadDialogContents;
51
52@end
53
54#endif  // CHROME_BROWSER_UI_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_H_
55
56