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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Details<RenderViewHost>(render_view_host)); | 55 content::Details<RenderViewHost>(render_view_host)); |
| 56 |
| 57 ChromeWebUI::RenderViewCreated(render_view_host); |
56 } | 58 } |
57 | 59 |
58 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { | 60 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { |
59 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 61 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
60 if (!delegate) | 62 if (!delegate) |
61 return; | 63 return; |
62 | 64 |
63 std::string json_retval; | 65 std::string json_retval; |
64 if (!args->empty() && !args->GetString(0, &json_retval)) | 66 if (!args->empty() && !args->GetString(0, &json_retval)) |
65 NOTREACHED() << "Could not read JSON argument"; | 67 NOTREACHED() << "Could not read JSON argument"; |
66 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); | 68 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); |
67 delegate->OnDialogCloseFromWebUI(); | 69 delegate->OnDialogCloseFromWebUI(); |
68 } | 70 } |
69 | 71 |
70 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { | 72 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { |
71 ConstrainedHtmlUIDelegate** property = | 73 ConstrainedHtmlUIDelegate** property = |
72 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); | 74 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); |
73 return property ? *property : NULL; | 75 return property ? *property : NULL; |
74 } | 76 } |
75 | 77 |
76 // static | 78 // static |
77 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 79 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
78 ConstrainedHtmlUI::GetPropertyAccessor() { | 80 ConstrainedHtmlUI::GetPropertyAccessor() { |
79 return g_constrained_html_ui_property_accessor.Get(); | 81 return g_constrained_html_ui_property_accessor.Get(); |
80 } | 82 } |
OLD | NEW |