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/web_dialog_ui.h" | 5 #include "chrome/browser/ui/webui/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/property_bag.h" | 10 #include "base/property_bag.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/ui/webui/web_dialog_delegate.h" | 12 #include "chrome/browser/ui/webui/web_dialog_delegate.h" |
13 #include "chrome/common/chrome_notification_types.h" | |
14 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
15 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
17 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
18 #include "content/public/browser/web_ui_message_handler.h" | 17 #include "content/public/browser/web_ui_message_handler.h" |
19 #include "content/public/common/bindings_policy.h" | 18 #include "content/public/common/bindings_policy.h" |
20 | 19 |
21 using content::RenderViewHost; | 20 using content::RenderViewHost; |
22 using content::WebUIMessageHandler; | 21 using content::WebUIMessageHandler; |
23 | 22 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 (*delegate)->GetWebUIMessageHandlers(&handlers); | 66 (*delegate)->GetWebUIMessageHandlers(&handlers); |
68 } | 67 } |
69 | 68 |
70 if (0 != (web_ui()->GetBindings() & content::BINDINGS_POLICY_WEB_UI)) | 69 if (0 != (web_ui()->GetBindings() & content::BINDINGS_POLICY_WEB_UI)) |
71 render_view_host->SetWebUIProperty("dialogArguments", dialog_args); | 70 render_view_host->SetWebUIProperty("dialogArguments", dialog_args); |
72 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); | 71 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); |
73 it != handlers.end(); ++it) { | 72 it != handlers.end(); ++it) { |
74 web_ui()->AddMessageHandler(*it); | 73 web_ui()->AddMessageHandler(*it); |
75 } | 74 } |
76 | 75 |
77 content::NotificationService::current()->Notify( | 76 if (delegate) |
78 chrome::NOTIFICATION_WEB_DIALOG_SHOWN, | 77 (*delegate)->OnDialogShown(web_ui(), render_view_host); |
79 content::Source<content::WebUI>(web_ui()), | |
80 content::Details<RenderViewHost>(render_view_host)); | |
81 } | 78 } |
82 | 79 |
83 void WebDialogUI::OnDialogClosed(const ListValue* args) { | 80 void WebDialogUI::OnDialogClosed(const ListValue* args) { |
84 WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( | 81 WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( |
85 web_ui()->GetWebContents()->GetPropertyBag()); | 82 web_ui()->GetWebContents()->GetPropertyBag()); |
86 if (delegate) { | 83 if (delegate) { |
87 std::string json_retval; | 84 std::string json_retval; |
88 if (args && !args->empty() && !args->GetString(0, &json_retval)) | 85 if (args && !args->empty() && !args->GetString(0, &json_retval)) |
89 NOTREACHED() << "Could not read JSON argument"; | 86 NOTREACHED() << "Could not read JSON argument"; |
90 | 87 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 122 } |
126 | 123 |
127 bool WebDialogDelegate::HandleAddNewContents( | 124 bool WebDialogDelegate::HandleAddNewContents( |
128 content::WebContents* source, | 125 content::WebContents* source, |
129 content::WebContents* new_contents, | 126 content::WebContents* new_contents, |
130 WindowOpenDisposition disposition, | 127 WindowOpenDisposition disposition, |
131 const gfx::Rect& initial_pos, | 128 const gfx::Rect& initial_pos, |
132 bool user_gesture) { | 129 bool user_gesture) { |
133 return false; | 130 return false; |
134 } | 131 } |
OLD | NEW |