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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 9 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 RegisterMessageCallback("DialogClose", | 42 RegisterMessageCallback("DialogClose", |
43 NewCallback(this, &ConstrainedHtmlUI::OnDialogCloseMessage)); | 43 NewCallback(this, &ConstrainedHtmlUI::OnDialogCloseMessage)); |
44 } | 44 } |
45 | 45 |
46 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { | 46 void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { |
47 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 47 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
48 if (!delegate) | 48 if (!delegate) |
49 return; | 49 return; |
50 | 50 |
51 std::string json_retval; | 51 std::string json_retval; |
52 if (!args->GetString(0, &json_retval)) | 52 if (!args->empty() && !args->GetString(0, &json_retval)) |
53 NOTREACHED() << "Could not read JSON argument"; | 53 NOTREACHED() << "Could not read JSON argument"; |
54 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); | 54 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); |
55 delegate->OnDialogCloseFromWebUI(); | 55 delegate->OnDialogCloseFromWebUI(); |
56 } | 56 } |
57 | 57 |
58 ConstrainedHtmlUIDelegate* | 58 ConstrainedHtmlUIDelegate* |
59 ConstrainedHtmlUI::GetConstrainedDelegate() { | 59 ConstrainedHtmlUI::GetConstrainedDelegate() { |
60 ConstrainedHtmlUIDelegate** property = | 60 ConstrainedHtmlUIDelegate** property = |
61 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); | 61 GetPropertyAccessor().GetProperty(tab_contents()->property_bag()); |
62 return property ? *property : NULL; | 62 return property ? *property : NULL; |
63 } | 63 } |
64 | 64 |
65 // static | 65 // static |
66 PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 66 PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
67 ConstrainedHtmlUI::GetPropertyAccessor() { | 67 ConstrainedHtmlUI::GetPropertyAccessor() { |
68 return g_constrained_html_ui_property_accessor.Get(); | 68 return g_constrained_html_ui_property_accessor.Get(); |
69 } | 69 } |
OLD | NEW |