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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 render_view_host->SetWebUIProperty("dialogArguments", dialog_args); | 66 render_view_host->SetWebUIProperty("dialogArguments", dialog_args); |
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::NotificationService::NoDetails()); | 76 content::Details<RenderViewHost>(render_view_host)); |
77 } | 77 } |
78 | 78 |
79 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { | 79 void HtmlDialogUI::OnDialogClosed(const ListValue* args) { |
80 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( | 80 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( |
81 tab_contents()->property_bag()); | 81 tab_contents()->property_bag()); |
82 if (delegate) { | 82 if (delegate) { |
83 std::string json_retval; | 83 std::string json_retval; |
84 if (args && !args->empty() && !args->GetString(0, &json_retval)) | 84 if (args && !args->empty() && !args->GetString(0, &json_retval)) |
85 NOTREACHED() << "Could not read JSON argument"; | 85 NOTREACHED() << "Could not read JSON argument"; |
86 | 86 |
87 (*delegate)->OnDialogClosed(json_retval); | 87 (*delegate)->OnDialogClosed(json_retval); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) | 91 ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) |
92 : HtmlDialogUI(tab_contents) { | 92 : HtmlDialogUI(tab_contents) { |
93 // Non-file based UI needs to not have access to the Web UI bindings | 93 // 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 | 94 // for security reasons. The code hosting the dialog should provide |
95 // dialog specific functionality through other bindings and methods | 95 // dialog specific functionality through other bindings and methods |
96 // that are scoped in duration to the dialogs existence. | 96 // that are scoped in duration to the dialogs existence. |
97 bindings_ &= ~content::BINDINGS_POLICY_WEB_UI; | 97 bindings_ &= ~content::BINDINGS_POLICY_WEB_UI; |
98 } | 98 } |
99 | 99 |
100 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { | 100 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { |
101 } | 101 } |
102 | 102 |
103 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { | 103 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { |
104 return false; | 104 return false; |
105 } | 105 } |
OLD | NEW |