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_GTK_HTML_DIALOG_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_HTML_DIALOG_GTK_H_ 7 #pragma once 8 9 #include <string> 10 #include <vector> 11 12 #include "base/memory/scoped_ptr.h" 13 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" 14 #include "chrome/browser/ui/webui/html_dialog_ui.h" 15 #include "ui/base/gtk/gtk_signal.h" 16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/size.h" 18 19 typedef struct _GtkWidget GtkWidget; 20 21 class Browser; 22 class Profile; 23 class TabContents; 24 class TabContentsContainerGtk; 25 class TabContentsWrapper; 26 27 class HtmlDialogGtk : public HtmlDialogTabContentsDelegate, 28 public HtmlDialogUIDelegate { 29 public: 30 HtmlDialogGtk(Profile* profile, HtmlDialogUIDelegate* delegate, 31 gfx::NativeWindow parent_window); 32 virtual ~HtmlDialogGtk(); 33 34 // Initializes the contents of the dialog (the DOMView and the callbacks). 35 gfx::NativeWindow InitDialog(); 36 37 // Overridden from HtmlDialogUI::Delegate: 38 virtual bool IsDialogModal() const; 39 virtual std::wstring GetDialogTitle() const; 40 virtual GURL GetDialogContentURL() const; 41 virtual void GetWebUIMessageHandlers( 42 std::vector<WebUIMessageHandler*>* handlers) const; 43 virtual void GetDialogSize(gfx::Size* size) const; 44 virtual std::string GetDialogArgs() const; 45 virtual void OnDialogClosed(const std::string& json_retval); OnCloseContents(TabContents * source,bool * out_close_dialog)46 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } 47 virtual bool ShouldShowDialogTitle() const; 48 49 // Overridden from TabContentsDelegate: 50 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); 51 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); 52 53 private: 54 CHROMEGTK_CALLBACK_1(HtmlDialogGtk, void, OnResponse, int); 55 56 // This view is a delegate to the HTML content since it needs to get notified 57 // about when the dialog is closing. For all other actions (besides dialog 58 // closing) we delegate to the creator of this view, which we keep track of 59 // using this variable. 60 HtmlDialogUIDelegate* delegate_; 61 62 gfx::NativeWindow parent_window_; 63 64 GtkWidget* dialog_; 65 66 scoped_ptr<TabContentsWrapper> tab_; 67 scoped_ptr<TabContentsContainerGtk> tab_contents_container_; 68 69 DISALLOW_COPY_AND_ASSIGN(HtmlDialogGtk); 70 }; 71 72 #endif // CHROME_BROWSER_UI_GTK_HTML_DIALOG_GTK_H_ 73