| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/html_dialog_ui.h" | 5 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/property_bag.h" | 10 #include "base/property_bag.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); | 67 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); |
| 68 it != handlers.end(); ++it) { | 68 it != handlers.end(); ++it) { |
| 69 (*it)->Attach(this); | 69 (*it)->Attach(this); |
| 70 AddMessageHandler(*it); | 70 AddMessageHandler(*it); |
| 71 } | 71 } |
| 72 | 72 |
| 73 content::NotificationService::current()->Notify( | 73 content::NotificationService::current()->Notify( |
| 74 chrome::NOTIFICATION_HTML_DIALOG_SHOWN, | 74 chrome::NOTIFICATION_HTML_DIALOG_SHOWN, |
| 75 content::Source<WebUI>(this), | 75 content::Source<WebUI>(this), |
| 76 content::Details<RenderViewHost>(render_view_host)); | 76 content::Details<RenderViewHost>(render_view_host)); |
| 77 |
| 78 ChromeWebUI::RenderViewCreated(render_view_host); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { | 81 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { |
| 80 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( | 82 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( |
| 81 tab_contents()->property_bag()); | 83 tab_contents()->property_bag()); |
| 82 if (delegate) { | 84 if (delegate) { |
| 83 std::string json_retval; | 85 std::string json_retval; |
| 84 if (args && !args->empty() && !args->GetString(0, &json_retval)) | 86 if (args && !args->empty() && !args->GetString(0, &json_retval)) |
| 85 NOTREACHED() << "Could not read JSON argument"; | 87 NOTREACHED() << "Could not read JSON argument"; |
| 86 | 88 |
| 87 (*delegate)->OnDialogClosed(json_retval); | 89 (*delegate)->OnDialogClosed(json_retval); |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 | 92 |
| 91 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) | 93 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) |
| 92 : HtmlDialogUI(tab_contents) { | 94 : HtmlDialogUI(tab_contents) { |
| 93 // Non-file based UI needs to not have access to the Web UI bindings | 95 // Non-file based UI needs to not have access to the Web UI bindings |
| 94 // for security reasons. The code hosting the dialog should provide | 96 // for security reasons. The code hosting the dialog should provide |
| 95 // dialog specific functionality through other bindings and methods | 97 // dialog specific functionality through other bindings and methods |
| 96 // that are scoped in duration to the dialogs existence. | 98 // that are scoped in duration to the dialogs existence. |
| 97 bindings_ &= ~content::BINDINGS_POLICY_WEB_UI; | 99 bindings_ &= ~content::BINDINGS_POLICY_WEB_UI; |
| 98 } | 100 } |
| 99 | 101 |
| 100 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { | 102 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { |
| 101 } | 103 } |
| 102 | 104 |
| 103 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { | 105 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { |
| 104 return false; | 106 return false; |
| 105 } | 107 } |
| OLD | NEW |