Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_ui.cc

Issue 614683002: Fix a DCHECK failure by registering a handler for 'dialogClose' message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #if defined(ENABLE_EXTENSIONS) 53 #if defined(ENABLE_EXTENSIONS)
54 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); 54 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
55 #endif 55 #endif
56 } 56 }
57 57
58 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { 58 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() {
59 } 59 }
60 60
61 void ConstrainedWebDialogUI::RenderViewCreated( 61 void ConstrainedWebDialogUI::RenderViewCreated(
62 RenderViewHost* render_view_host) { 62 RenderViewHost* render_view_host) {
63 // Add a "dialogClose" callback which matches WebDialogUI behavior.
64 web_ui()->RegisterMessageCallback("dialogClose",
65 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage,
66 base::Unretained(this)));
67
63 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 68 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
64 if (!delegate) 69 if (!delegate)
65 return; 70 return;
66 71
67 ui::WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); 72 ui::WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate();
68 std::vector<WebUIMessageHandler*> handlers; 73 std::vector<WebUIMessageHandler*> handlers;
69 dialog_delegate->GetWebUIMessageHandlers(&handlers); 74 dialog_delegate->GetWebUIMessageHandlers(&handlers);
70 render_view_host->SetWebUIProperty("dialogArguments", 75 render_view_host->SetWebUIProperty("dialogArguments",
71 dialog_delegate->GetDialogArgs()); 76 dialog_delegate->GetDialogArgs());
72 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); 77 for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin();
73 it != handlers.end(); ++it) { 78 it != handlers.end(); ++it) {
74 web_ui()->AddMessageHandler(*it); 79 web_ui()->AddMessageHandler(*it);
75 } 80 }
76 81
77 // Add a "dialogClose" callback which matches WebDialogUI behavior.
78 web_ui()->RegisterMessageCallback("dialogClose",
79 base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage,
80 base::Unretained(this)));
81
82 dialog_delegate->OnDialogShown(web_ui(), render_view_host); 82 dialog_delegate->OnDialogShown(web_ui(), render_view_host);
83 } 83 }
84 84
85 void ConstrainedWebDialogUI::OnDialogCloseMessage(const base::ListValue* args) { 85 void ConstrainedWebDialogUI::OnDialogCloseMessage(const base::ListValue* args) {
86 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 86 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
87 if (!delegate) 87 if (!delegate)
88 return; 88 return;
89 89
90 std::string json_retval; 90 std::string json_retval;
91 if (!args->empty() && !args->GetString(0, &json_retval)) 91 if (!args->empty() && !args->GetString(0, &json_retval))
(...skipping 11 matching lines...) Expand all
103 } 103 }
104 104
105 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { 105 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() {
106 ConstrainedWebDialogDelegateUserData* user_data = 106 ConstrainedWebDialogDelegateUserData* user_data =
107 static_cast<ConstrainedWebDialogDelegateUserData*>( 107 static_cast<ConstrainedWebDialogDelegateUserData*>(
108 web_ui()->GetWebContents()-> 108 web_ui()->GetWebContents()->
109 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); 109 GetUserData(&kConstrainedWebDialogDelegateUserDataKey));
110 110
111 return user_data ? user_data->delegate() : NULL; 111 return user_data ? user_data->delegate() : NULL;
112 } 112 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698