OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/native_dialog_window.h" | 5 #include "chrome/browser/chromeos/native_dialog_window.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/gtk_signal.h" | 9 #include "app/gtk_signal.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/chromeos/frame/bubble_window.h" | 12 #include "chrome/browser/chromeos/frame/bubble_window.h" |
| 13 #include "chrome/browser/views/window.h" |
13 #include "views/controls/native/native_view_host.h" | 14 #include "views/controls/native/native_view_host.h" |
14 #include "views/window/dialog_delegate.h" | 15 #include "views/window/dialog_delegate.h" |
15 #include "views/window/non_client_view.h" | 16 #include "views/window/non_client_view.h" |
16 #include "views/window/window.h" | 17 #include "views/window/window.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const int kDialogPadding = 3; | 21 const int kDialogPadding = 3; |
21 | 22 |
22 const char kNativeDialogHost[] = "_chromeos_native_dialog_host_"; | 23 const char kNativeDialogHost[] = "_chromeos_native_dialog_host_"; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 gtk_container_add(GTK_CONTAINER(contents), dialog_contents); | 212 gtk_container_add(GTK_CONTAINER(contents), dialog_contents); |
212 g_object_unref(dialog_contents); | 213 g_object_unref(dialog_contents); |
213 gtk_widget_hide(dialog_); | 214 gtk_widget_hide(dialog_); |
214 | 215 |
215 g_object_set_data(G_OBJECT(dialog_), kNativeDialogHost, | 216 g_object_set_data(G_OBJECT(dialog_), kNativeDialogHost, |
216 reinterpret_cast<gpointer>(this)); | 217 reinterpret_cast<gpointer>(this)); |
217 | 218 |
218 gtk_widget_show_all(contents); | 219 gtk_widget_show_all(contents); |
219 | 220 |
220 contents_view_ = new views::NativeViewHost(); | 221 contents_view_ = new views::NativeViewHost(); |
| 222 // TODO(xiyuan): Find a better way to get proper background. |
221 contents_view_->set_background(views::Background::CreateSolidBackground( | 223 contents_view_->set_background(views::Background::CreateSolidBackground( |
222 BubbleWindow::kBackgroundColor)); | 224 BubbleWindow::kBackgroundColor)); |
223 AddChildView(contents_view_); | 225 AddChildView(contents_view_); |
224 contents_view_->Attach(contents); | 226 contents_view_->Attach(contents); |
225 | 227 |
226 g_signal_connect(window()->GetNativeWindow(), "check-resize", | 228 g_signal_connect(window()->GetNativeWindow(), "check-resize", |
227 G_CALLBACK(&OnCheckResizeThunk), this); | 229 G_CALLBACK(&OnCheckResizeThunk), this); |
228 | 230 |
229 // Use gtk's default size if size is not speicified. | 231 // Use gtk's default size if size is not speicified. |
230 if (size_.IsEmpty()) { | 232 if (size_.IsEmpty()) { |
(...skipping 27 matching lines...) Expand all Loading... |
258 preferred_size_.set_height(min_size_.height()); | 260 preferred_size_.set_height(min_size_.height()); |
259 } | 261 } |
260 | 262 |
261 void ShowNativeDialog(gfx::NativeWindow parent, | 263 void ShowNativeDialog(gfx::NativeWindow parent, |
262 gfx::NativeView native_dialog, | 264 gfx::NativeView native_dialog, |
263 int flags, | 265 int flags, |
264 const gfx::Size& size, | 266 const gfx::Size& size, |
265 const gfx::Size& min_size) { | 267 const gfx::Size& min_size) { |
266 NativeDialogHost* native_dialog_host = | 268 NativeDialogHost* native_dialog_host = |
267 new NativeDialogHost(native_dialog, flags, size, min_size); | 269 new NativeDialogHost(native_dialog, flags, size, min_size); |
268 BubbleWindow::Create(parent, gfx::Rect(), native_dialog_host); | 270 browser::CreateViewsWindow(parent, gfx::Rect(), native_dialog_host); |
269 native_dialog_host->window()->Show(); | 271 native_dialog_host->window()->Show(); |
270 } | 272 } |
271 | 273 |
272 gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog) { | 274 gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog) { |
273 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( | 275 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( |
274 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); | 276 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); |
275 return host ? host->window()->GetNativeWindow() : NULL; | 277 return host ? host->window()->GetNativeWindow() : NULL; |
276 } | 278 } |
277 | 279 |
278 gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog) { | 280 gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog) { |
279 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( | 281 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( |
280 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); | 282 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); |
281 return host ? host->bounds() : gfx::Rect(); | 283 return host ? host->bounds() : gfx::Rect(); |
282 } | 284 } |
283 | 285 |
284 } // namespace chromeos | 286 } // namespace chromeos |
OLD | NEW |