| 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_web_dialog_delegate_base.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/web_dialog_delegate.h" | |
| 11 #include "chrome/browser/ui/webui/web_dialog_ui.h" | |
| 12 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
| 13 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 15 #include "ui/base/gtk/gtk_hig_constants.h" | 13 #include "ui/base/gtk/gtk_hig_constants.h" |
| 16 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 15 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 16 #include "ui/web_dialogs/web_dialog_ui.h" |
| 17 | 17 |
| 18 using content::WebContents; | 18 using content::WebContents; |
| 19 | 19 |
| 20 class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate, | 20 class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate, |
| 21 public ConstrainedWebDialogDelegate { | 21 public ConstrainedWebDialogDelegate { |
| 22 public: | 22 public: |
| 23 ConstrainedWebDialogDelegateGtk( | 23 ConstrainedWebDialogDelegateGtk( |
| 24 Profile* profile, | 24 Profile* profile, |
| 25 WebDialogDelegate* delegate, | 25 web_dialogs::WebDialogDelegate* delegate, |
| 26 WebDialogWebContentsDelegate* tab_delegate); | 26 web_dialogs::WebDialogWebContentsDelegate* tab_delegate); |
| 27 | 27 |
| 28 virtual ~ConstrainedWebDialogDelegateGtk() {} | 28 virtual ~ConstrainedWebDialogDelegateGtk() {} |
| 29 | 29 |
| 30 void set_window(ConstrainedWindow* window) { | 30 void set_window(ConstrainedWindow* window) { |
| 31 return impl_->set_window(window); | 31 return impl_->set_window(window); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // ConstrainedWebDialogDelegate interface | 34 // ConstrainedWebDialogDelegate interface |
| 35 virtual const WebDialogDelegate* | 35 virtual const web_dialogs::WebDialogDelegate* |
| 36 GetWebDialogDelegate() const OVERRIDE { | 36 GetWebDialogDelegate() const OVERRIDE { |
| 37 return impl_->GetWebDialogDelegate(); | 37 return impl_->GetWebDialogDelegate(); |
| 38 } | 38 } |
| 39 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { | 39 virtual web_dialogs::WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { |
| 40 return impl_->GetWebDialogDelegate(); | 40 return impl_->GetWebDialogDelegate(); |
| 41 } | 41 } |
| 42 virtual void OnDialogCloseFromWebUI() OVERRIDE { | 42 virtual void OnDialogCloseFromWebUI() OVERRIDE { |
| 43 return impl_->OnDialogCloseFromWebUI(); | 43 return impl_->OnDialogCloseFromWebUI(); |
| 44 } | 44 } |
| 45 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { | 45 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { |
| 46 return impl_->ReleaseTabContentsOnDialogClose(); | 46 return impl_->ReleaseTabContentsOnDialogClose(); |
| 47 } | 47 } |
| 48 virtual ConstrainedWindow* window() OVERRIDE { | 48 virtual ConstrainedWindow* window() OVERRIDE { |
| 49 return impl_->window(); | 49 return impl_->window(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 72 private: | 72 private: |
| 73 scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; | 73 scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; |
| 74 | 74 |
| 75 TabContentsContainerGtk tab_contents_container_; | 75 TabContentsContainerGtk tab_contents_container_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); | 77 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk( | 80 ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk( |
| 81 Profile* profile, | 81 Profile* profile, |
| 82 WebDialogDelegate* delegate, | 82 web_dialogs::WebDialogDelegate* delegate, |
| 83 WebDialogWebContentsDelegate* tab_delegate) | 83 web_dialogs::WebDialogWebContentsDelegate* tab_delegate) |
| 84 : impl_(new ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate
)), | 84 : impl_(new ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate
)), |
| 85 tab_contents_container_(NULL) { | 85 tab_contents_container_(NULL) { |
| 86 tab_contents_container_.SetTab(tab()); | 86 tab_contents_container_.SetTab(tab()); |
| 87 | 87 |
| 88 gfx::Size dialog_size; | 88 gfx::Size dialog_size; |
| 89 delegate->GetDialogSize(&dialog_size); | 89 delegate->GetDialogSize(&dialog_size); |
| 90 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_.widget()), | 90 gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_.widget()), |
| 91 dialog_size.width(), | 91 dialog_size.width(), |
| 92 dialog_size.height()); | 92 dialog_size.height()); |
| 93 | 93 |
| 94 gtk_widget_show_all(GetWidgetRoot()); | 94 gtk_widget_show_all(GetWidgetRoot()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // static | 97 // static |
| 98 ConstrainedWebDialogDelegate* | 98 ConstrainedWebDialogDelegate* |
| 99 ConstrainedWebDialogUI::CreateConstrainedWebDialog( | 99 ConstrainedWebDialogUI::CreateConstrainedWebDialog( |
| 100 Profile* profile, | 100 Profile* profile, |
| 101 WebDialogDelegate* delegate, | 101 web_dialogs::WebDialogDelegate* delegate, |
| 102 WebDialogWebContentsDelegate* tab_delegate, | 102 web_dialogs::WebDialogWebContentsDelegate* tab_delegate, |
| 103 TabContentsWrapper* overshadowed) { | 103 TabContentsWrapper* overshadowed) { |
| 104 ConstrainedWebDialogDelegateGtk* constrained_delegate = | 104 ConstrainedWebDialogDelegateGtk* constrained_delegate = |
| 105 new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate); | 105 new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate); |
| 106 ConstrainedWindow* constrained_window = | 106 ConstrainedWindow* constrained_window = |
| 107 new ConstrainedWindowGtk(overshadowed, constrained_delegate); | 107 new ConstrainedWindowGtk(overshadowed, constrained_delegate); |
| 108 constrained_delegate->set_window(constrained_window); | 108 constrained_delegate->set_window(constrained_window); |
| 109 return constrained_delegate; | 109 return constrained_delegate; |
| 110 } | 110 } |
| OLD | NEW |