diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 00:38:12 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 00:38:12 +0000 |
commit | 73852b8f9c03c6b7a27436f828ed888f71232257 (patch) | |
tree | da07fd53317f13964f93383f9591fcdfdfa61ea7 /chrome/browser/dom_ui/html_dialog_ui.cc | |
parent | 564551a2ece790b22fd2a70aeb8591805fe943be (diff) | |
download | chromium_src-73852b8f9c03c6b7a27436f828ed888f71232257.zip chromium_src-73852b8f9c03c6b7a27436f828ed888f71232257.tar.gz chromium_src-73852b8f9c03c6b7a27436f828ed888f71232257.tar.bz2 |
[Large; Chromium OS] Work to host the cloud print dialog when built
for Chromium OS. Currently disabled by default behind a command line
switch, and containing a non-real URL for now, this code is at
prototype level. It works (when enabled and pointed at a functioning
cloud print service URL), has the beginnings of some unit tests, and
has the beginnings of deeper communication with the dialog contents,
and it shuts off the DOM UI access from the dialog contents.
Patch contributed by Scott Byer
Review URL: http://codereview.chromium.org/1769006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui/html_dialog_ui.cc')
-rw-r--r-- | chrome/browser/dom_ui/html_dialog_ui.cc | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/chrome/browser/dom_ui/html_dialog_ui.cc b/chrome/browser/dom_ui/html_dialog_ui.cc index 739a4c4..f93e9ca 100644 --- a/chrome/browser/dom_ui/html_dialog_ui.cc +++ b/chrome/browser/dom_ui/html_dialog_ui.cc @@ -7,8 +7,10 @@ #include "base/callback.h" #include "base/singleton.h" #include "base/values.h" +#include "chrome/browser/dom_ui/dom_ui_util.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/common/bindings_policy.h" HtmlDialogUI::HtmlDialogUI(TabContents* tab_contents) : DOMUI(tab_contents) { } @@ -32,28 +34,6 @@ PropertyAccessor<HtmlDialogUIDelegate*>& HtmlDialogUI::GetPropertyAccessor() { //////////////////////////////////////////////////////////////////////////////// // Private: -// Helper function to read the JSON string from the Value parameter. -static std::string GetJsonResponse(const Value* content) { - if (!content || !content->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return std::string(); - } - const ListValue* args = static_cast<const ListValue*>(content); - if (args->GetSize() != 1) { - NOTREACHED(); - return std::string(); - } - - std::string result; - Value* value = NULL; - if (!args->Get(0, &value) || !value->GetAsString(&result)) { - NOTREACHED(); - return std::string(); - } - - return result; -} - void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { // Hook up the javascript function calls, also known as chrome.send("foo") // calls in the HTML, to the actual C++ functions. @@ -70,7 +50,8 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { (*delegate)->GetDOMMessageHandlers(&handlers); } - render_view_host->SetDOMUIProperty("dialogArguments", dialog_args); + if (0 != (bindings_ & BindingsPolicy::DOM_UI)) + render_view_host->SetDOMUIProperty("dialogArguments", dialog_args); for (std::vector<DOMMessageHandler*>::iterator it = handlers.begin(); it != handlers.end(); ++it) { (*it)->Attach(this); @@ -82,5 +63,18 @@ void HtmlDialogUI::OnDialogClosed(const Value* content) { HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( tab_contents()->property_bag()); if (delegate) - (*delegate)->OnDialogClosed(GetJsonResponse(content)); + (*delegate)->OnDialogClosed( + dom_ui_util::GetJsonResponseFromFirstArgumentInList(content)); +} + +ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) + : HtmlDialogUI(tab_contents) { + // Non-file based UI needs to not have access to the DOM UI bindings + // for security reasons. The code hosting the dialog should provide + // dialog specific functionality through other bindings and methods + // that are scoped in duration to the dialogs existence. + bindings_ &= ~BindingsPolicy::DOM_UI; +} + +ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { } |