summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 22:28:57 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 22:28:57 +0000
commit0c631f2617b70445dd7d116f0711cd991d2adffe (patch)
treeac8819b828ff7e62c7558d3da7148d8a47ad3bc6
parentb2841b0739079820ae5a3f405fa777e5109a2e79 (diff)
downloadchromium_src-0c631f2617b70445dd7d116f0711cd991d2adffe.zip
chromium_src-0c631f2617b70445dd7d116f0711cd991d2adffe.tar.gz
chromium_src-0c631f2617b70445dd7d116f0711cd991d2adffe.tar.bz2
[GTK] - constrained html dialog gtk implementation
BUG=58022 TEST=none Review URL: http://codereview.chromium.org/3767005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62661 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/dom_ui.h6
-rw-r--r--chrome/browser/gtk/constrained_html_dialog_gtk.cc81
-rw-r--r--chrome/chrome_browser.gypi1
3 files changed, 85 insertions, 3 deletions
diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h
index 42ffe2a..5e76b7c 100644
--- a/chrome/browser/dom_ui/dom_ui.h
+++ b/chrome/browser/dom_ui/dom_ui.h
@@ -141,13 +141,13 @@ class DOMUI {
// The DOMMessageHandlers we own.
std::vector<DOMMessageHandler*> handlers_;
+ // Non-owning pointer to the TabContents this DOMUI is associated with.
+ TabContents* tab_contents_;
+
private:
// Execute a string of raw Javascript on the page.
void ExecuteJavascript(const std::wstring& javascript);
- // Non-owning pointer to the TabContents this DOMUI is associated with.
- TabContents* tab_contents_;
-
// A map of message name -> message handling callback.
typedef std::map<std::string, MessageCallback*> MessageCallbackMap;
MessageCallbackMap message_callbacks_;
diff --git a/chrome/browser/gtk/constrained_html_dialog_gtk.cc b/chrome/browser/gtk/constrained_html_dialog_gtk.cc
new file mode 100644
index 0000000..6fd36f1
--- /dev/null
+++ b/chrome/browser/gtk/constrained_html_dialog_gtk.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2010 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/dom_ui/constrained_html_dialog.h"
+
+#include "gfx/rect.h"
+#include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h"
+#include "chrome/browser/dom_ui/html_dialog_ui.h"
+#include "chrome/browser/gtk/constrained_window_gtk.h"
+#include "chrome/browser/gtk/tab_contents_container_gtk.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "ipc/ipc_message.h"
+
+class ConstrainedHtmlDialogGtk : public ConstrainedHtmlDialog,
+ public ConstrainedWindowGtkDelegate,
+ public HtmlDialogTabContentsDelegate {
+ public:
+ ConstrainedHtmlDialogGtk(Profile* profile,
+ HtmlDialogUIDelegate* delegate);
+
+ virtual ~ConstrainedHtmlDialogGtk();
+
+ // ConstrainedHtmlDialog -----------------------------------------------------
+ virtual ConstrainedWindowDelegate* GetConstrainedWindowDelegate() {
+ return this;
+ }
+
+ // ConstrainedWindowGtkDelegate ----------------------------------------------
+ virtual GtkWidget* GetWidgetRoot() {
+ return tab_contents_container_.widget();
+ }
+
+ virtual void DeleteDelegate() {
+ delete this;
+ }
+
+ // HtmlDialogTabContentsDelegate ---------------------------------------------
+ void MoveContents(TabContents* source, const gfx::Rect& pos) {}
+ void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
+ void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
+
+ private:
+ TabContentsContainerGtk tab_contents_container_;
+};
+
+ConstrainedHtmlDialogGtk::ConstrainedHtmlDialogGtk(
+ Profile* profile,
+ HtmlDialogUIDelegate* delegate)
+ : ConstrainedHtmlDialog(profile, delegate),
+ HtmlDialogTabContentsDelegate(profile),
+ tab_contents_container_(NULL) {
+ tab_contents_ = new TabContents(profile, NULL, MSG_ROUTING_NONE, NULL, NULL);
+ tab_contents_->set_delegate(this);
+ tab_contents_->controller().LoadURL(delegate->GetDialogContentURL(),
+ GURL(), PageTransition::START_PAGE);
+ tab_contents_container_.SetTabContents(tab_contents_);
+
+ 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());
+
+ InitializeDOMUI(tab_contents_->render_view_host());
+
+ gtk_widget_show_all(GetWidgetRoot());
+}
+
+ConstrainedHtmlDialogGtk::~ConstrainedHtmlDialogGtk() {
+ delete tab_contents_;
+ // Prevent other accesses to |tab_contents_| (during superclass destruction,
+ // for example).
+ tab_contents_ = NULL;
+}
+
+// static
+ConstrainedHtmlDialog* ConstrainedHtmlDialog::CreateConstrainedHTMLDialog(
+ Profile* profile, HtmlDialogUIDelegate* delegate) {
+ return new ConstrainedHtmlDialogGtk(profile, delegate);
+}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 950e9a5..dc5f4b6 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1749,6 +1749,7 @@
'browser/gtk/clear_browsing_data_dialog_gtk.h',
'browser/gtk/collected_cookies_gtk.cc',
'browser/gtk/collected_cookies_gtk.h',
+ 'browser/gtk/constrained_html_dialog_gtk.cc',
'browser/gtk/constrained_window_gtk.cc',
'browser/gtk/constrained_window_gtk.h',
'browser/gtk/content_setting_bubble_gtk.cc',