blob: 4b21aff767207dc8dff030a18ba806ea6b2484b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
#pragma once
#include "base/compiler_specific.h"
#include "content/public/browser/web_ui_controller.h"
class ConstrainedWindow;
class HtmlDialogUIDelegate;
class Profile;
class RenderViewHost;
class TabContentsWrapper;
namespace base {
template<class T> class PropertyAccessor;
}
class ConstrainedHtmlUIDelegate {
public:
virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0;
// Called when the dialog is being closed in response to a "DialogClose"
// message from WebUI.
virtual void OnDialogCloseFromWebUI() = 0;
// If called, on dialog closure, the dialog will release its WebContents
// instead of destroying it. After which point, the caller will own the
// released WebContents.
virtual void ReleaseTabContentsOnDialogClose() = 0;
// Returns the ConstrainedWindow.
virtual ConstrainedWindow* window() = 0;
// Returns the TabContentsWrapper owned by the constrained window.
virtual TabContentsWrapper* tab() = 0;
protected:
virtual ~ConstrainedHtmlUIDelegate() {}
};
// ConstrainedHtmlUI is a facility to show HTML WebUI content
// in a tab-modal constrained dialog. It is implemented as an adapter
// between an HtmlDialogUI object and a ConstrainedWindow object.
//
// Since ConstrainedWindow requires platform-specific delegate
// implementations, this class is just a factory stub.
class ConstrainedHtmlUI : public content::WebUIController {
public:
explicit ConstrainedHtmlUI(content::WebUI* web_ui);
virtual ~ConstrainedHtmlUI();
// WebUIController implementation:
virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
// Create a constrained HTML dialog. The actual object that gets created
// is a ConstrainedHtmlUIDelegate, which later triggers construction of a
// ConstrainedHtmlUI object.
static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog(
Profile* profile,
HtmlDialogUIDelegate* delegate,
TabContentsWrapper* overshadowed);
// Returns a property accessor that can be used to set the
// ConstrainedHtmlUIDelegate property on a WebContents.
static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>&
GetPropertyAccessor();
protected:
// Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate.
// Returns NULL if that property is not set.
ConstrainedHtmlUIDelegate* GetConstrainedDelegate();
private:
// JS Message Handler
void OnDialogCloseMessage(const base::ListValue* args);
DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI);
};
#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
|