OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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.h" | 5 #include "chrome/browser/ui/webui/constrained_html_ui.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 8 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
9 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
10 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 10 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 HtmlDialogUIDelegate* html_delegate_; | 64 HtmlDialogUIDelegate* html_delegate_; |
65 | 65 |
66 // The constrained window that owns |this|. Saved so we can close it later. | 66 // The constrained window that owns |this|. Saved so we can close it later. |
67 ConstrainedWindow* window_; | 67 ConstrainedWindow* window_; |
68 }; | 68 }; |
69 | 69 |
70 ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( | 70 ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( |
71 Profile* profile, | 71 Profile* profile, |
72 HtmlDialogUIDelegate* delegate) | 72 HtmlDialogUIDelegate* delegate) |
73 : HtmlDialogTabContentsDelegate(profile), | 73 : views::WidgetGtk(new views::Widget), |
| 74 HtmlDialogTabContentsDelegate(profile), |
74 html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), | 75 html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), |
75 tab_container_(NULL), | 76 tab_container_(NULL), |
76 html_delegate_(delegate), | 77 html_delegate_(delegate), |
77 window_(NULL) { | 78 window_(NULL) { |
78 CHECK(delegate); | 79 CHECK(delegate); |
79 html_tab_contents_.set_delegate(this); | 80 html_tab_contents_.set_delegate(this); |
80 | 81 |
81 // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. | 82 // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. |
82 ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( | 83 ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( |
83 html_tab_contents_.property_bag(), this); | 84 html_tab_contents_.property_bag(), this); |
84 html_tab_contents_.controller().LoadURL(delegate->GetDialogContentURL(), | 85 html_tab_contents_.controller().LoadURL(delegate->GetDialogContentURL(), |
85 GURL(), | 86 GURL(), |
86 PageTransition::START_PAGE); | 87 PageTransition::START_PAGE); |
87 | 88 |
88 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 89 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
| 90 params.native_widget = this; |
89 GetWidget()->Init(params); | 91 GetWidget()->Init(params); |
90 | 92 |
91 tab_container_ = new TabContentsContainer; | 93 tab_container_ = new TabContentsContainer; |
92 SetContentsView(tab_container_); | 94 GetWidget()->SetContentsView(tab_container_); |
93 tab_container_->ChangeTabContents(&html_tab_contents_); | 95 tab_container_->ChangeTabContents(&html_tab_contents_); |
94 | 96 |
95 gfx::Size dialog_size; | 97 gfx::Size dialog_size; |
96 html_delegate_->GetDialogSize(&dialog_size); | 98 html_delegate_->GetDialogSize(&dialog_size); |
97 gtk_widget_set_size_request(GetWidgetRoot(), | 99 gtk_widget_set_size_request(GetWidgetRoot(), |
98 dialog_size.width(), | 100 dialog_size.width(), |
99 dialog_size.height()); | 101 dialog_size.height()); |
100 } | 102 } |
101 | 103 |
102 ConstrainedHtmlDelegateGtk::~ConstrainedHtmlDelegateGtk() { | 104 ConstrainedHtmlDelegateGtk::~ConstrainedHtmlDelegateGtk() { |
(...skipping 12 matching lines...) Expand all Loading... |
115 Profile* profile, | 117 Profile* profile, |
116 HtmlDialogUIDelegate* delegate, | 118 HtmlDialogUIDelegate* delegate, |
117 TabContents* container) { | 119 TabContents* container) { |
118 ConstrainedHtmlDelegateGtk* constrained_delegate = | 120 ConstrainedHtmlDelegateGtk* constrained_delegate = |
119 new ConstrainedHtmlDelegateGtk(profile, delegate); | 121 new ConstrainedHtmlDelegateGtk(profile, delegate); |
120 ConstrainedWindow* constrained_window = | 122 ConstrainedWindow* constrained_window = |
121 container->CreateConstrainedDialog(constrained_delegate); | 123 container->CreateConstrainedDialog(constrained_delegate); |
122 constrained_delegate->set_window(constrained_window); | 124 constrained_delegate->set_window(constrained_window); |
123 return constrained_window; | 125 return constrained_window; |
124 } | 126 } |
OLD | NEW |