Home | History | Annotate | Download | only in webui
      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_WEBUI_CONSTRAINED_HTML_UI_H_
      6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
      7 #pragma once
      8 
      9 #include <vector>
     10 
     11 #include "content/browser/tab_contents/constrained_window.h"
     12 #include "content/browser/webui/web_ui.h"
     13 #include "content/common/property_bag.h"
     14 
     15 class HtmlDialogUIDelegate;
     16 class Profile;
     17 class RenderViewHost;
     18 class TabContents;
     19 
     20 class ConstrainedHtmlUIDelegate {
     21  public:
     22   virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0;
     23 
     24   // Called when the dialog should close.
     25   virtual void OnDialogClose() = 0;
     26 };
     27 
     28 // ConstrainedHtmlUI is a facility to show HTML WebUI content
     29 // in a tab-modal constrained dialog.  It is implemented as an adapter
     30 // between an HtmlDialogUI object and a ConstrainedWindow object.
     31 //
     32 // Since ConstrainedWindow requires platform-specific delegate
     33 // implementations, this class is just a factory stub.
     34 class ConstrainedHtmlUI : public WebUI {
     35  public:
     36   explicit ConstrainedHtmlUI(TabContents* contents);
     37   virtual ~ConstrainedHtmlUI();
     38 
     39   virtual void RenderViewCreated(RenderViewHost* render_view_host);
     40 
     41   // Create a constrained HTML dialog. The actual object that gets created
     42   // is a ConstrainedHtmlUIDelegate, which later triggers construction of a
     43   // ConstrainedHtmlUI object.
     44   static ConstrainedWindow* CreateConstrainedHtmlDialog(
     45       Profile* profile,
     46       HtmlDialogUIDelegate* delegate,
     47       TabContents* overshadowed);
     48 
     49   // Returns a property accessor that can be used to set the
     50   // ConstrainedHtmlUIDelegate property on a TabContents.
     51   static PropertyAccessor<ConstrainedHtmlUIDelegate*>&
     52       GetPropertyAccessor();
     53 
     54  private:
     55   // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate.
     56   // Returns NULL if that property is not set.
     57   ConstrainedHtmlUIDelegate* GetConstrainedDelegate();
     58 
     59   // JS Message Handler
     60   void OnDialogClose(const ListValue* args);
     61 
     62   DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI);
     63 };
     64 
     65 #endif  // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
     66