OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/web_dialogs/web_dialog_ui.h" | 5 #include "ui/web_dialogs/web_dialog_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 static_cast<WebDialogDelegateUserData*>( | 72 static_cast<WebDialogDelegateUserData*>( |
73 web_contents->GetUserData(&kWebDialogDelegateUserDataKey)); | 73 web_contents->GetUserData(&kWebDialogDelegateUserDataKey)); |
74 | 74 |
75 return user_data ? user_data->delegate() : NULL; | 75 return user_data ? user_data->delegate() : NULL; |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 void WebDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { | 79 void WebDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { |
80 // Hook up the javascript function calls, also known as chrome.send("foo") | 80 // Hook up the javascript function calls, also known as chrome.send("foo") |
81 // calls in the HTML, to the actual C++ functions. | 81 // calls in the HTML, to the actual C++ functions. |
82 web_ui()->RegisterMessageCallback("DialogClose", | 82 web_ui()->RegisterMessageCallback("dialogClose", |
83 base::Bind(&WebDialogUI::OnDialogClosed, base::Unretained(this))); | 83 base::Bind(&WebDialogUI::OnDialogClosed, base::Unretained(this))); |
84 | 84 |
85 // Pass the arguments to the renderer supplied by the delegate. | 85 // Pass the arguments to the renderer supplied by the delegate. |
86 std::string dialog_args; | 86 std::string dialog_args; |
87 std::vector<WebUIMessageHandler*> handlers; | 87 std::vector<WebUIMessageHandler*> handlers; |
88 WebDialogDelegate* delegate = GetDelegate(web_ui()->GetWebContents()); | 88 WebDialogDelegate* delegate = GetDelegate(web_ui()->GetWebContents()); |
89 if (delegate) { | 89 if (delegate) { |
90 dialog_args = delegate->GetDialogArgs(); | 90 dialog_args = delegate->GetDialogArgs(); |
91 delegate->GetWebUIMessageHandlers(&handlers); | 91 delegate->GetWebUIMessageHandlers(&handlers); |
92 } | 92 } |
(...skipping 26 matching lines...) Expand all Loading... |
119 // for security reasons. The code hosting the dialog should provide | 119 // for security reasons. The code hosting the dialog should provide |
120 // dialog specific functionality through other bindings and methods | 120 // dialog specific functionality through other bindings and methods |
121 // that are scoped in duration to the dialogs existence. | 121 // that are scoped in duration to the dialogs existence. |
122 web_ui->SetBindings(web_ui->GetBindings() & ~content::BINDINGS_POLICY_WEB_UI); | 122 web_ui->SetBindings(web_ui->GetBindings() & ~content::BINDINGS_POLICY_WEB_UI); |
123 } | 123 } |
124 | 124 |
125 ExternalWebDialogUI::~ExternalWebDialogUI() { | 125 ExternalWebDialogUI::~ExternalWebDialogUI() { |
126 } | 126 } |
127 | 127 |
128 } // namespace ui | 128 } // namespace ui |
OLD | NEW |