| 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/memory/ptr_util.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
| 15 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
| 16 #include "content/public/common/bindings_policy.h" | 17 #include "content/public/common/bindings_policy.h" |
| 17 #include "ui/web_dialogs/web_dialog_delegate.h" | 18 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 18 | 19 |
| 19 using content::RenderFrameHost; | 20 using content::RenderFrameHost; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. | 54 // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. |
| 54 } | 55 } |
| 55 | 56 |
| 56 void WebDialogUI::CloseDialog(const base::ListValue* args) { | 57 void WebDialogUI::CloseDialog(const base::ListValue* args) { |
| 57 OnDialogClosed(args); | 58 OnDialogClosed(args); |
| 58 } | 59 } |
| 59 | 60 |
| 60 // static | 61 // static |
| 61 void WebDialogUI::SetDelegate(content::WebContents* web_contents, | 62 void WebDialogUI::SetDelegate(content::WebContents* web_contents, |
| 62 WebDialogDelegate* delegate) { | 63 WebDialogDelegate* delegate) { |
| 63 web_contents->SetUserData(&kWebDialogDelegateUserDataKey, | 64 web_contents->SetUserData( |
| 64 new WebDialogDelegateUserData(delegate)); | 65 &kWebDialogDelegateUserDataKey, |
| 66 base::MakeUnique<WebDialogDelegateUserData>(delegate)); |
| 65 } | 67 } |
| 66 | 68 |
| 67 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
| 68 // Private: | 70 // Private: |
| 69 | 71 |
| 70 WebDialogDelegate* WebDialogUI::GetDelegate( | 72 WebDialogDelegate* WebDialogUI::GetDelegate( |
| 71 content::WebContents* web_contents) { | 73 content::WebContents* web_contents) { |
| 72 WebDialogDelegateUserData* user_data = | 74 WebDialogDelegateUserData* user_data = |
| 73 static_cast<WebDialogDelegateUserData*>( | 75 static_cast<WebDialogDelegateUserData*>( |
| 74 web_contents->GetUserData(&kWebDialogDelegateUserDataKey)); | 76 web_contents->GetUserData(&kWebDialogDelegateUserDataKey)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (delegate) { | 110 if (delegate) { |
| 109 std::string json_retval; | 111 std::string json_retval; |
| 110 if (args && !args->empty() && !args->GetString(0, &json_retval)) | 112 if (args && !args->empty() && !args->GetString(0, &json_retval)) |
| 111 NOTREACHED() << "Could not read JSON argument"; | 113 NOTREACHED() << "Could not read JSON argument"; |
| 112 | 114 |
| 113 delegate->OnDialogCloseFromWebUI(json_retval); | 115 delegate->OnDialogCloseFromWebUI(json_retval); |
| 114 } | 116 } |
| 115 } | 117 } |
| 116 | 118 |
| 117 } // namespace ui | 119 } // namespace ui |
| OLD | NEW |