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 "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ui::WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); | 60 ui::WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); |
61 std::vector<WebUIMessageHandler*> handlers; | 61 std::vector<WebUIMessageHandler*> handlers; |
62 dialog_delegate->GetWebUIMessageHandlers(&handlers); | 62 dialog_delegate->GetWebUIMessageHandlers(&handlers); |
63 render_view_host->SetWebUIProperty("dialogArguments", | 63 render_view_host->SetWebUIProperty("dialogArguments", |
64 dialog_delegate->GetDialogArgs()); | 64 dialog_delegate->GetDialogArgs()); |
65 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); | 65 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); |
66 it != handlers.end(); ++it) { | 66 it != handlers.end(); ++it) { |
67 web_ui()->AddMessageHandler(*it); | 67 web_ui()->AddMessageHandler(*it); |
68 } | 68 } |
69 | 69 |
70 // Add a "DialogClose" callback which matches WebDialogUI behavior. | 70 // Add a "dialogClose" callback which matches WebDialogUI behavior. |
71 web_ui()->RegisterMessageCallback("DialogClose", | 71 web_ui()->RegisterMessageCallback("dialogClose", |
72 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage, | 72 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage, |
73 base::Unretained(this))); | 73 base::Unretained(this))); |
74 | 74 |
75 dialog_delegate->OnDialogShown(web_ui(), render_view_host); | 75 dialog_delegate->OnDialogShown(web_ui(), render_view_host); |
76 } | 76 } |
77 | 77 |
78 void ConstrainedWebDialogUI::OnDialogCloseMessage(const base::ListValue* args) { | 78 void ConstrainedWebDialogUI::OnDialogCloseMessage(const base::ListValue* args) { |
79 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); | 79 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); |
80 if (!delegate) | 80 if (!delegate) |
81 return; | 81 return; |
(...skipping 14 matching lines...) Expand all Loading... |
96 } | 96 } |
97 | 97 |
98 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { | 98 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { |
99 ConstrainedWebDialogDelegateUserData* user_data = | 99 ConstrainedWebDialogDelegateUserData* user_data = |
100 static_cast<ConstrainedWebDialogDelegateUserData*>( | 100 static_cast<ConstrainedWebDialogDelegateUserData*>( |
101 web_ui()->GetWebContents()-> | 101 web_ui()->GetWebContents()-> |
102 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); | 102 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); |
103 | 103 |
104 return user_data ? user_data->delegate() : NULL; | 104 return user_data ? user_data->delegate() : NULL; |
105 } | 105 } |
OLD | NEW |