| 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/constrained_html_ui.h" | 5 #include "chrome/browser/ui/webui/constrained_html_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Add a "DialogClose" callback which matches HTMLDialogUI behavior. | 47 // Add a "DialogClose" callback which matches HTMLDialogUI behavior. |
| 48 RegisterMessageCallback("DialogClose", | 48 RegisterMessageCallback("DialogClose", |
| 49 base::Bind(&ConstrainedHtmlUI::OnDialogCloseMessage, | 49 base::Bind(&ConstrainedHtmlUI::OnDialogCloseMessage, |
| 50 base::Unretained(this))); | 50 base::Unretained(this))); |
| 51 | 51 |
| 52 content::NotificationService::current()->Notify( | 52 content::NotificationService::current()->Notify( |
| 53 chrome::NOTIFICATION_HTML_DIALOG_SHOWN, | 53 chrome::NOTIFICATION_HTML_DIALOG_SHOWN, |
| 54 content::Source<WebUI>(this), | 54 content::Source<WebUI>(this), |
| 55 content::NotificationService::NoDetails()); | 55 content::Details<RenderViewHost>(render_view_host)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { | 58 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { |
| 59 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 59 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
| 60 if (!delegate) | 60 if (!delegate) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 std::string json_retval; | 63 std::string json_retval; |
| 64 if (!args->empty() && !args->GetString(0, &json_retval)) | 64 if (!args->empty() && !args->GetString(0, &json_retval)) |
| 65 NOTREACHED() << "Could not read JSON argument"; | 65 NOTREACHED() << "Could not read JSON argument"; |
| 66 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); | 66 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); |
| 67 delegate->OnDialogCloseFromWebUI(); | 67 delegate->OnDialogCloseFromWebUI(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { | 70 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { |
| 71 ConstrainedHtmlUIDelegate** property = | 71 ConstrainedHtmlUIDelegate** property = |
| 72 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); | 72 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); |
| 73 return property ? *property : NULL; | 73 return property ? *property : NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 77 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
| 78 ConstrainedHtmlUI::GetPropertyAccessor() { | 78 ConstrainedHtmlUI::GetPropertyAccessor() { |
| 79 return g_constrained_html_ui_property_accessor.Get(); | 79 return g_constrained_html_ui_property_accessor.Get(); |
| 80 } | 80 } |
| OLD | NEW |