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