diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
commit | 5835871a6f47c28ff022c9284e2aa1f0d1761ab3 (patch) | |
tree | 52eba6e7556400aa0b519216907844110bc8ce8a /chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc | |
parent | bc6d23dc0d55aeda0be5ae9d799046ff6a43db14 (diff) | |
download | chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.zip chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.gz chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.bz2 |
Web-ify a bunch of these names. I am going to move some of the framework code here down to ui/web_dialogs in a future cl, hence the namespaces.
HtmlDialogUI->WebDialogUI
HtmlDialogUIDelegate->WebDialogDelegate
HtmlDialogTabContentsDelegate->WebDialogWebContentsDelegate
HtmlDialogView->WebDialogView
HtmlDialogController->WebDialogController
HtmlDialogGtk -> WebDialogGtk
BUG=none
TEST=none
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/10214001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc')
-rw-r--r-- | chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc new file mode 100644 index 0000000..5db681c --- /dev/null +++ b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" + +#include "chrome/browser/ui/gtk/constrained_window_gtk.h" +#include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" +#include "content/public/browser/notification_source.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "ui/base/gtk/gtk_hig_constants.h" +#include "ui/gfx/size.h" + +using content::WebContents; + +class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate, + public ConstrainedWebDialogDelegate { + public: + ConstrainedWebDialogDelegateGtk( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); + + virtual ~ConstrainedWebDialogDelegateGtk() {} + + void set_window(ConstrainedWindow* window) { + return impl_->set_window(window); + } + + // ConstrainedWebDialogDelegate interface + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE { + return impl_->GetWebDialogDelegate(); + } + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { + return impl_->GetWebDialogDelegate(); + } + virtual void OnDialogCloseFromWebUI() OVERRIDE { + return impl_->OnDialogCloseFromWebUI(); + } + virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { + return impl_->ReleaseTabContentsOnDialogClose(); + } + virtual ConstrainedWindow* window() OVERRIDE { + return impl_->window(); + } + virtual TabContentsWrapper* tab() OVERRIDE { + return impl_->tab(); + } + + // ConstrainedWindowGtkDelegate interface + virtual GtkWidget* GetWidgetRoot() OVERRIDE { + return tab_contents_container_.widget(); + } + virtual GtkWidget* GetFocusWidget() OVERRIDE { + return tab()->web_contents()->GetContentNativeView(); + } + virtual void DeleteDelegate() OVERRIDE { + if (!impl_->closed_via_webui()) + GetWebDialogDelegate()->OnDialogClosed(""); + delete this; + } + virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { + *color = ui::kGdkWhite; + return true; + } + + private: + scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; + + TabContentsContainerGtk tab_contents_container_; + + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); +}; + +ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : impl_(new ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate)), + tab_contents_container_(NULL) { + tab_contents_container_.SetTab(tab()); + + gfx::Size dialog_size; + delegate->GetDialogSize(&dialog_size); + gtk_widget_set_size_request(GTK_WIDGET(tab_contents_container_.widget()), + dialog_size.width(), + dialog_size.height()); + + gtk_widget_show_all(GetWidgetRoot()); +} + +// static +ConstrainedWebDialogDelegate* + ConstrainedWebDialogUI::CreateConstrainedWebDialog( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, + TabContentsWrapper* overshadowed) { + ConstrainedWebDialogDelegateGtk* constrained_delegate = + new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate); + ConstrainedWindow* constrained_window = + new ConstrainedWindowGtk(overshadowed, constrained_delegate); + constrained_delegate->set_window(constrained_window); + return constrained_delegate; +} |