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/callback.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
8 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
11 #include "content/browser/renderer_host/render_view_host.h" | 12 #include "content/browser/renderer_host/render_view_host.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "content/common/bindings_policy.h" | 14 #include "content/common/bindings_policy.h" |
14 #include "content/common/notification_service.h" | 15 #include "content/common/notification_service.h" |
15 | 16 |
16 static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > | 17 static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > |
17 g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); | 18 g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); |
(...skipping 22 matching lines...) Expand all Loading... |
40 return g_html_dialog_ui_property_accessor.Get(); | 41 return g_html_dialog_ui_property_accessor.Get(); |
41 } | 42 } |
42 | 43 |
43 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
44 // Private: | 45 // Private: |
45 | 46 |
46 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { | 47 void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { |
47 // Hook up the javascript function calls, also known as chrome.send("foo") | 48 // Hook up the javascript function calls, also known as chrome.send("foo") |
48 // calls in the HTML, to the actual C++ functions. | 49 // calls in the HTML, to the actual C++ functions. |
49 RegisterMessageCallback("DialogClose", | 50 RegisterMessageCallback("DialogClose", |
50 NewCallback(this, &HtmlDialogUI::OnDialogClosed)); | 51 base::Bind(&HtmlDialogUI::OnDialogClosed, base::Unretained(this))); |
51 | 52 |
52 // Pass the arguments to the renderer supplied by the delegate. | 53 // Pass the arguments to the renderer supplied by the delegate. |
53 std::string dialog_args; | 54 std::string dialog_args; |
54 std::vector<WebUIMessageHandler*> handlers; | 55 std::vector<WebUIMessageHandler*> handlers; |
55 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( | 56 HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( |
56 tab_contents()->property_bag()); | 57 tab_contents()->property_bag()); |
57 if (delegate) { | 58 if (delegate) { |
58 dialog_args = (*delegate)->GetDialogArgs(); | 59 dialog_args = (*delegate)->GetDialogArgs(); |
59 (*delegate)->GetWebUIMessageHandlers(&handlers); | 60 (*delegate)->GetWebUIMessageHandlers(&handlers); |
60 } | 61 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // that are scoped in duration to the dialogs existence. | 94 // that are scoped in duration to the dialogs existence. |
94 bindings_ &= ~BindingsPolicy::WEB_UI; | 95 bindings_ &= ~BindingsPolicy::WEB_UI; |
95 } | 96 } |
96 | 97 |
97 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { | 98 ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { |
98 } | 99 } |
99 | 100 |
100 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { | 101 bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) { |
101 return false; | 102 return false; |
102 } | 103 } |
OLD | NEW |