OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" |
6 | 6 |
7 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 7 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
8 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 8 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
10 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 10 #include "chrome/browser/ui/webui/web_dialog_ui.h" |
11 #include "content/public/browser/notification_source.h" | 11 #include "content/public/browser/notification_source.h" |
12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "ui/base/gtk/gtk_hig_constants.h" | 14 #include "ui/base/gtk/gtk_hig_constants.h" |
15 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
16 | 16 |
17 using content::WebContents; | 17 using content::WebContents; |
18 | 18 |
19 class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, | 19 class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate, |
20 public ConstrainedHtmlUIDelegate { | 20 public ConstrainedWebDialogDelegate { |
21 public: | 21 public: |
22 ConstrainedHtmlDelegateGtk(Profile* profile, | 22 ConstrainedWebDialogDelegateGtk( |
23 HtmlDialogUIDelegate* delegate, | 23 Profile* profile, |
24 HtmlDialogTabContentsDelegate* tab_delegate); | 24 WebDialogDelegate* delegate, |
| 25 WebDialogWebContentsDelegate* tab_delegate); |
25 | 26 |
26 virtual ~ConstrainedHtmlDelegateGtk() {} | 27 virtual ~ConstrainedWebDialogDelegateGtk() {} |
27 | 28 |
28 void set_window(ConstrainedWindow* window) { | 29 void set_window(ConstrainedWindow* window) { |
29 return impl_->set_window(window); | 30 return impl_->set_window(window); |
30 } | 31 } |
31 | 32 |
32 // ConstrainedHtmlUIDelegate interface | 33 // ConstrainedWebDialogDelegate interface |
33 virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE { | 34 virtual const WebDialogDelegate* |
34 return impl_->GetHtmlDialogUIDelegate(); | 35 GetWebDialogDelegate() const OVERRIDE { |
| 36 return impl_->GetWebDialogDelegate(); |
35 } | 37 } |
36 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE { | 38 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { |
37 return impl_->GetHtmlDialogUIDelegate(); | 39 return impl_->GetWebDialogDelegate(); |
38 } | 40 } |
39 virtual void OnDialogCloseFromWebUI() OVERRIDE { | 41 virtual void OnDialogCloseFromWebUI() OVERRIDE { |
40 return impl_->OnDialogCloseFromWebUI(); | 42 return impl_->OnDialogCloseFromWebUI(); |
41 } | 43 } |
42 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { | 44 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { |
43 return impl_->ReleaseTabContentsOnDialogClose(); | 45 return impl_->ReleaseTabContentsOnDialogClose(); |
44 } | 46 } |
45 virtual ConstrainedWindow* window() OVERRIDE { | 47 virtual ConstrainedWindow* window() OVERRIDE { |
46 return impl_->window(); | 48 return impl_->window(); |
47 } | 49 } |
48 virtual TabContentsWrapper* tab() OVERRIDE { | 50 virtual TabContentsWrapper* tab() OVERRIDE { |
49 return impl_->tab(); | 51 return impl_->tab(); |
50 } | 52 } |
51 | 53 |
52 // ConstrainedWindowGtkDelegate interface | 54 // ConstrainedWindowGtkDelegate interface |
53 virtual GtkWidget* GetWidgetRoot() OVERRIDE { | 55 virtual GtkWidget* GetWidgetRoot() OVERRIDE { |
54 return tab_contents_container_.widget(); | 56 return tab_contents_container_.widget(); |
55 } | 57 } |
56 virtual GtkWidget* GetFocusWidget() OVERRIDE { | 58 virtual GtkWidget* GetFocusWidget() OVERRIDE { |
57 return tab()->web_contents()->GetContentNativeView(); | 59 return tab()->web_contents()->GetContentNativeView(); |
58 } | 60 } |
59 virtual void DeleteDelegate() OVERRIDE { | 61 virtual void DeleteDelegate() OVERRIDE { |
60 if (!impl_->closed_via_webui()) | 62 if (!impl_->closed_via_webui()) |
61 GetHtmlDialogUIDelegate()->OnDialogClosed(""); | 63 GetWebDialogDelegate()->OnDialogClosed(""); |
62 delete this; | 64 delete this; |
63 } | 65 } |
64 virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { | 66 virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { |
65 *color = ui::kGdkWhite; | 67 *color = ui::kGdkWhite; |
66 return true; | 68 return true; |
67 } | 69 } |
68 | 70 |
69 private: | 71 private: |
70 scoped_ptr<ConstrainedHtmlUIDelegateImpl> impl_; | 72 scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; |
71 | 73 |
72 TabContentsContainerGtk tab_contents_container_; | 74 TabContentsContainerGtk tab_contents_container_; |
73 | 75 |
74 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlDelegateGtk); | 76 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); |
75 }; | 77 }; |
76 | 78 |
77 ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( | 79 ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk( |
78 Profile* profile, | 80 Profile* profile, |
79 HtmlDialogUIDelegate* delegate, | 81 WebDialogDelegate* delegate, |
80 HtmlDialogTabContentsDelegate* tab_delegate) | 82 WebDialogWebContentsDelegate* tab_delegate) |
81 : impl_(new ConstrainedHtmlUIDelegateImpl(profile, delegate, tab_delegate)), | 83 : impl_(new ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate
)), |
82 tab_contents_container_(NULL) { | 84 tab_contents_container_(NULL) { |
83 tab_contents_container_.SetTab(tab()); | 85 tab_contents_container_.SetTab(tab()); |
84 | 86 |
85 gfx::Size dialog_size; | 87 gfx::Size dialog_size; |
86 delegate->GetDialogSize(&dialog_size); | 88 delegate->GetDialogSize(&dialog_size); |
87 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_.widget()), | 89 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_.widget()), |
88 dialog_size.width(), | 90 dialog_size.width(), |
89 dialog_size.height()); | 91 dialog_size.height()); |
90 | 92 |
91 gtk_widget_show_all(GetWidgetRoot()); | 93 gtk_widget_show_all(GetWidgetRoot()); |
92 } | 94 } |
93 | 95 |
94 // static | 96 // static |
95 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( | 97 ConstrainedWebDialogDelegate* |
96 Profile* profile, | 98 ConstrainedWebDialogUI::CreateConstrainedWebDialog( |
97 HtmlDialogUIDelegate* delegate, | 99 Profile* profile, |
98 HtmlDialogTabContentsDelegate* tab_delegate, | 100 WebDialogDelegate* delegate, |
99 TabContentsWrapper* overshadowed) { | 101 WebDialogWebContentsDelegate* tab_delegate, |
100 ConstrainedHtmlDelegateGtk* constrained_delegate = | 102 TabContentsWrapper* overshadowed) { |
101 new ConstrainedHtmlDelegateGtk(profile, delegate, tab_delegate); | 103 ConstrainedWebDialogDelegateGtk* constrained_delegate = |
| 104 new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate); |
102 ConstrainedWindow* constrained_window = | 105 ConstrainedWindow* constrained_window = |
103 new ConstrainedWindowGtk(overshadowed, constrained_delegate); | 106 new ConstrainedWindowGtk(overshadowed, constrained_delegate); |
104 constrained_delegate->set_window(constrained_window); | 107 constrained_delegate->set_window(constrained_window); |
105 return constrained_delegate; | 108 return constrained_delegate; |
106 } | 109 } |
OLD | NEW |