summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/constrained_html_ui.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-27 05:58:07 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-27 05:58:07 +0000
commit265a149061df91fb2c794a877994a6b9b17c0395 (patch)
treede806aa83fd520d92ede0e06923744158e73eeaa /chrome/browser/ui/webui/constrained_html_ui.cc
parent4ff6ce9702a91c52892786464b15f3c8588d4070 (diff)
downloadchromium_src-265a149061df91fb2c794a877994a6b9b17c0395.zip
chromium_src-265a149061df91fb2c794a877994a6b9b17c0395.tar.gz
chromium_src-265a149061df91fb2c794a877994a6b9b17c0395.tar.bz2
WebUI: Move more files from chrome/browser/webui to chrome/browser/ui/webui.
I'm moving the files I have found with: $ ls chrome/browser/webui | grep _ui BUG=59946 TEST=trybots Review URL: http://codereview.chromium.org/6599024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui/constrained_html_ui.cc')
-rw-r--r--chrome/browser/ui/webui/constrained_html_ui.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/chrome/browser/ui/webui/constrained_html_ui.cc b/chrome/browser/ui/webui/constrained_html_ui.cc
new file mode 100644
index 0000000..68dd024
--- /dev/null
+++ b/chrome/browser/ui/webui/constrained_html_ui.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2011 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_html_ui.h"
+
+#include "base/lazy_instance.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/webui/html_dialog_ui.h"
+#include "chrome/common/bindings_policy.h"
+#include "content/browser/webui/web_ui_util.h"
+
+static base::LazyInstance<PropertyAccessor<ConstrainedHtmlUIDelegate*> >
+ g_constrained_html_ui_property_accessor(base::LINKER_INITIALIZED);
+
+ConstrainedHtmlUI::ConstrainedHtmlUI(TabContents* contents)
+ : WebUI(contents) {
+}
+
+ConstrainedHtmlUI::~ConstrainedHtmlUI() {
+}
+
+void ConstrainedHtmlUI::RenderViewCreated(
+ RenderViewHost* render_view_host) {
+ ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate();
+ if (!delegate)
+ return;
+
+ HtmlDialogUIDelegate* dialog_delegate = delegate->GetHtmlDialogUIDelegate();
+ std::vector<WebUIMessageHandler*> handlers;
+ dialog_delegate->GetWebUIMessageHandlers(&handlers);
+ render_view_host->SetWebUIProperty("dialogArguments",
+ dialog_delegate->GetDialogArgs());
+ for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
+ it != handlers.end(); ++it) {
+ (*it)->Attach(this);
+ AddMessageHandler(*it);
+ }
+
+ // Add a "DialogClose" callback which matches HTMLDialogUI behavior.
+ RegisterMessageCallback("DialogClose",
+ NewCallback(this, &ConstrainedHtmlUI::OnDialogClose));
+}
+
+void ConstrainedHtmlUI::OnDialogClose(const ListValue* args) {
+ ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate();
+ if (!delegate)
+ return;
+
+ delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(
+ web_ui_util::GetJsonResponseFromFirstArgumentInList(args));
+ delegate->OnDialogClose();
+}
+
+ConstrainedHtmlUIDelegate*
+ ConstrainedHtmlUI::GetConstrainedDelegate() {
+ ConstrainedHtmlUIDelegate** property =
+ GetPropertyAccessor().GetProperty(tab_contents()->property_bag());
+ return property ? *property : NULL;
+}
+
+// static
+PropertyAccessor<ConstrainedHtmlUIDelegate*>&
+ ConstrainedHtmlUI::GetPropertyAccessor() {
+ return g_constrained_html_ui_property_accessor.Get();
+}