| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ | 6 #define CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/gfx/native_widget_types.h" |
| 11 #include "base/gfx/size.h" | 12 #include "base/gfx/size.h" |
| 12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/browser.h" | |
| 14 #include "chrome/browser/dom_ui/html_dialog_ui.h" | 14 #include "chrome/browser/dom_ui/html_dialog_ui.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 15 #include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h" |
| 16 | 16 |
| 17 typedef struct _GtkWidget GtkWidget; | 17 typedef struct _GtkWidget GtkWidget; |
| 18 | 18 |
| 19 class Browser; |
| 20 class Profile; |
| 19 class TabContents; | 21 class TabContents; |
| 20 class TabContentsContainerGtk; | 22 class TabContentsContainerGtk; |
| 21 | 23 |
| 22 class HtmlDialogGtk : public TabContentsDelegate, | 24 class HtmlDialogGtk : public HtmlDialogTabContentsDelegate, |
| 23 public HtmlDialogUIDelegate { | 25 public HtmlDialogUIDelegate { |
| 24 public: | 26 public: |
| 25 HtmlDialogGtk(Browser* parent_browser, HtmlDialogUIDelegate* delegate); | 27 HtmlDialogGtk(Profile* profile, HtmlDialogUIDelegate* delegate, |
| 28 gfx::NativeWindow parent_window); |
| 26 virtual ~HtmlDialogGtk(); | 29 virtual ~HtmlDialogGtk(); |
| 27 | 30 |
| 28 static void ShowHtmlDialogGtk(Browser* browser, | 31 static void ShowHtmlDialogGtk(Browser* browser, |
| 29 HtmlDialogUIDelegate* delegate); | 32 HtmlDialogUIDelegate* delegate, |
| 33 gfx::NativeWindow parent_window); |
| 30 // Initializes the contents of the dialog (the DOMView and the callbacks). | 34 // Initializes the contents of the dialog (the DOMView and the callbacks). |
| 31 void InitDialog(); | 35 void InitDialog(); |
| 32 | 36 |
| 33 // Overridden from HtmlDialogUI::Delegate: | 37 // Overridden from HtmlDialogUI::Delegate: |
| 34 virtual bool IsDialogModal() const; | 38 virtual bool IsDialogModal() const; |
| 35 virtual std::wstring GetDialogTitle() const; | 39 virtual std::wstring GetDialogTitle() const; |
| 36 virtual GURL GetDialogContentURL() const; | 40 virtual GURL GetDialogContentURL() const; |
| 37 virtual void GetDOMMessageHandlers( | 41 virtual void GetDOMMessageHandlers( |
| 38 std::vector<DOMMessageHandler*>* handlers) const; | 42 std::vector<DOMMessageHandler*>* handlers) const; |
| 39 virtual void GetDialogSize(gfx::Size* size) const; | 43 virtual void GetDialogSize(gfx::Size* size) const; |
| 40 virtual std::string GetDialogArgs() const; | 44 virtual std::string GetDialogArgs() const; |
| 41 virtual void OnDialogClosed(const std::string& json_retval); | 45 virtual void OnDialogClosed(const std::string& json_retval); |
| 42 | 46 |
| 43 // Overridden from TabContentsDelegate: | 47 // Overridden from TabContentsDelegate: |
| 44 virtual void OpenURLFromTab(TabContents* source, | |
| 45 const GURL& url, | |
| 46 const GURL& referrer, | |
| 47 WindowOpenDisposition disposition, | |
| 48 PageTransition::Type transition); | |
| 49 virtual void NavigationStateChanged(const TabContents* source, | |
| 50 unsigned changed_flags); | |
| 51 virtual void ReplaceContents(TabContents* source, | |
| 52 TabContents* new_contents); | |
| 53 virtual void AddNewContents(TabContents* source, | |
| 54 TabContents* new_contents, | |
| 55 WindowOpenDisposition disposition, | |
| 56 const gfx::Rect& initial_pos, | |
| 57 bool user_gesture); | |
| 58 virtual void ActivateContents(TabContents* contents); | |
| 59 virtual void LoadingStateChanged(TabContents* source); | |
| 60 virtual void CloseContents(TabContents* source); | |
| 61 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); | 48 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); |
| 62 virtual bool IsPopup(TabContents* source); | |
| 63 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); | 49 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); |
| 64 virtual void URLStarredChanged(TabContents* source, bool starred); | |
| 65 virtual void UpdateTargetURL(TabContents* source, const GURL& url); | |
| 66 | 50 |
| 67 private: | 51 private: |
| 68 static void OnResponse(GtkWidget* widget, int response, | 52 static void OnResponse(GtkWidget* widget, int response, |
| 69 HtmlDialogGtk* dialog); | 53 HtmlDialogGtk* dialog); |
| 70 | 54 |
| 71 // The Browser object which created this html dialog; we send all | |
| 72 // window opening/navigations to this object. | |
| 73 Browser* parent_browser_; | |
| 74 | |
| 75 // This view is a delegate to the HTML content since it needs to get notified | 55 // This view is a delegate to the HTML content since it needs to get notified |
| 76 // about when the dialog is closing. For all other actions (besides dialog | 56 // about when the dialog is closing. For all other actions (besides dialog |
| 77 // closing) we delegate to the creator of this view, which we keep track of | 57 // closing) we delegate to the creator of this view, which we keep track of |
| 78 // using this variable. | 58 // using this variable. |
| 79 HtmlDialogUIDelegate* delegate_; | 59 HtmlDialogUIDelegate* delegate_; |
| 80 | 60 |
| 61 gfx::NativeWindow parent_window_; |
| 62 |
| 81 GtkWidget* dialog_; | 63 GtkWidget* dialog_; |
| 82 | 64 |
| 83 scoped_ptr<TabContents> tab_contents_; | 65 scoped_ptr<TabContents> tab_contents_; |
| 84 scoped_ptr<TabContentsContainerGtk> tab_contents_container_; | 66 scoped_ptr<TabContentsContainerGtk> tab_contents_container_; |
| 85 | 67 |
| 86 DISALLOW_COPY_AND_ASSIGN(HtmlDialogGtk); | 68 DISALLOW_COPY_AND_ASSIGN(HtmlDialogGtk); |
| 87 }; | 69 }; |
| 88 | 70 |
| 89 #endif // CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ | 71 #endif // CHROME_BROWSER_GTK_HTML_DIALOG_GTK_H_ |
| OLD | NEW |