summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/constrained_html_ui.h
blob: b9dc0eeab712efa94323caba9d06c4bfbd1022e3 (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
// Copyright (c) 2010 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_DOM_UI_CONSTRAINED_HTML_UI_H_
#define CHROME_BROWSER_DOM_UI_CONSTRAINED_HTML_UI_H_
#pragma once

#include <vector>

#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#include "chrome/common/property_bag.h"

class HtmlDialogUIDelegate;
class Profile;
class RenderViewHost;
class TabContents;

class ConstrainedHtmlUIDelegate {
 public:
  virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0;

  // Called when the dialog should close.
  virtual void OnDialogClose() = 0;
};

// ConstrainedHtmlUI is a facility to show HTML DOM_UI 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 DOMUI {
 public:
  explicit ConstrainedHtmlUI(TabContents* contents);
  virtual ~ConstrainedHtmlUI();

  virtual void RenderViewCreated(RenderViewHost* render_view_host);

  // Create a constrained HTML dialog. The actual object that gets created
  // is a ConstrainedHtmlUIDelegate, which later triggers construction of a
  // ConstrainedHtmlUI object.
  static void CreateConstrainedHtmlDialog(Profile* profile,
                                          HtmlDialogUIDelegate* delegate,
                                          TabContents* overshadowed);

  // Returns a property accessor that can be used to set the
  // ConstrainedHtmlUIDelegate property on a TabContents.
  static PropertyAccessor<ConstrainedHtmlUIDelegate*>&
      GetPropertyAccessor();

 private:
  // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate.
  // Returns NULL if that property is not set.
  ConstrainedHtmlUIDelegate* GetConstrainedDelegate();

  // JS Message Handler
  void OnDialogClose(const ListValue* args);

  DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI);
};

#endif  // CHROME_BROWSER_DOM_UI_CONSTRAINED_HTML_UI_H_